PHP shebang

I’ve posted a number of times in the past about how it is possible to run PHP scripts from the command line and here dedicate a post to showing how a PHP script can be run by adding a shebang line and running it as if it were any other command.

Categories PHP

Catch mutiple exception types with PHP

PHP’s try..catch can be used to catch multiple exception types. If the try block could cause one of several different exceptions they can each be handled separately with their own catch section.

Categories PHP

Catch uncaught exceptions with PHP

This is the third in a series of posts about exception handling in PHP and looks at how to specify a default exception handler. The default handler is called for any exceptions that occur which are not enclosed in a try..catch block.

Categories PHP

Type hinting with PHP

PHP has supported type hinting for parameter functions from version 5.0 for objects and from version 5.1 for arrays. Type hinting means the function specifies what type the parameter must be and if it is not of the correct type an error will occur. Type hinting is not supported for other types, e.g. for strings and integers.

Categories PHP