June 2017
Intermediate to advanced
536 pages
9h 49m
English
With the introduction of throwables, PHP pretty much aligned its efforts around error detection, reporting, and handling. Developers are able to use the try...catch...finally blocks to handle the exceptions as they see fit. The possibility to use multiple catch blocks can give finer control over the response to certain types of exceptions. Sometimes, however, there are groups of exceptions we would like to respond equally. In PHP 7.1, exception handling was further refined to accommodate this challenge.
Let's take a look at the following PHP 5.x example:
try { // ... } catch (\InvalidArgumentException $e) { // ... } catch (\LengthException $e) { // ... }catch (Exception $e) { // ... } finally { // ... ...Read now
Unlock full access