PHP 7 And The Fatal Errors
Php 24-Oct-2019

PHP 7 And The Fatal Errors

PHP as a language has irritating in handing of fatal errors; these errors can’t be handling before touches the browser’s window. One by one error results in set error handler () this lead to stop all script execution. PHP developers also worried to fatal errors and want to trap them as rare exceptions. Google searches also helps in revealing fatal error, but now PHP7 is there that decreases these fatal errors significantly.

PHP 7

Now developers can save their days and avoid to disgrace of using ini_set (‘display_errors’,’0′); and also avoid to tolerate the pain for use of “@” suppression character. One kind of developers thinks that there is no other choice, others hope that some type of guidance is prove to be an effective prevention against its use. (I realize 99% PHP developers use error suppression operator (I one of them) so I’m expecting any PHP developer who sees this, to down vote me but please bookmark this so that you can comeback and change it to an up vote in a couple

of years, when you realize I was right.) stackoverflow In PHP 7, exception will be thrown after a fatal and retrievable error (E_ERROR and E_RECOVERABLE_ERROR) occurs, rather than stopping script execution; Fatal errors static exist for some conditions, such as running out of memory, and still behave as early mentioned by instantly faltering script execution. The uncaught exception will also continue to be a fatal error in PHP7. It’s miserable if exception arise from an error that was fatal in PHP5.x goes uncaught, it will still be a fatal error in PHP 7.

Everyone is discussing the performance speed of PHP7. Tumbling PHP5 and adopting PHP7 the reason behind it is fatal errors however it depends on the developers part and re-factoring situations that before were left there, so the best practice is catch those errors and also write code excludes the possibility of error.

Two Steps

PHP frameworks and the Content Management systems will not re-factor their code and provide well robust solutions through upgrading fully with PHP 7.

Codes Support PHP 5.x & 7 Exceptions

Multiple catch block can used for catching exception in PHP 5.x & 7 with same code, Throwable first, then catching Exception. After PHP 5.x support is no longer needed then the block catching Exception can be removed.

Expect to see many fixes at Github by this code

try {
    // Code Possible throw Exception or Error.
} Catch (Throwable $t) {
    // Executed only in PHP 7, will not match in PHP 5.x
} Catch (Exception $e) {
    // Run only in PHP 5.x, will not  happen  in PHP 7
}

This will create a code base to maintaining backwards compatibility. Delegating-code to handle best-case scenario is an older version of PHP, then it must be writing forward to the latest version. This is the status quo for PHP open source projects. Open Source Zombies take Over the World!. Open source projects are better choices and this tool is not use as another excuse to re-write PHP functionality with any other design pattern.

Users are free to create error and extend Error to create your own Error classes. The important question is that what situations would throw an instance of a class extending Error and Exception?