June 2017
Intermediate to advanced
536 pages
9h 49m
English
The exceptions in PHP are not a new concept. They have been around ever since PHP 5 was released. However, they did not encompass all of PHP's error handling because errors were not considered to be exceptions. PHP, at the time, had two-error handling systems. This made it tricky to deal with, as traditional errors were not catchable via the try...catch blocks exceptions. Certain tricks were possible, where one could have used the set_error_handler() function in order to set a user-defined error handler function, basically listening for errors and turning them into exceptions.
Let's look at the following example:
<?phpclass Mailer{ private $transport; public function __construct(Transport $transport) { $this->transport = $transport ...