Safe PHP – Built-In Functions Rewritten to Throw Exceptions

In the project Safe PHP by David Ngrier, all PHP functions that return false are rewritten to throw exceptions instead. The readme describes the problem with functions returning false before exception handling came to PHP: Most PHP core functions have been written before exception handling was added to the language. Therefore, most PHP functions do not throw exceptions. Instead, they return false in case of error. The readme further goes on to explain what the code would look like to check for false using the current language capabilities: The Safe PHP solution for this is as follows:

Read Full Article at

Tags: , , , , , , ,