Unfortunately I’m still not able to write thousands of lines without making a mistake, I’m still trying of course! In most situations you’ll get enough information from PHP to fix the problem quickly but sometimes you have to navigate through a bunch of files until you’ve found the origin of the problem.
This can be annoying and time consuming.
Luckily Joseph Lenton wrote a rather nice tool which shows you more information and it’s also very easy to use. There’s no PHP module involved, no installed required like XDebug.
Get the source of php_error.php from this page: https://github.com/JosephLenton/PHP-Error.
After that all you need to do is to include this at the top of the first file you’re working with:
require( 'php_error.php' ); \php_error\reportErrors();
After that, you’ll see a nice output like this if you make a mistake:
It might happen that you’re getting a bunch of stuff which you don’t care about. That’s probably because you have some warning or notices about deprecated functions. You can either fix them or if you’re lazy, change the error_reporting like this:
require( 'php_error.php' ); $options = array( 'snippet_num_lines' => 10, 'error_reporting_off' => 0, 'error_reporting_on' => E_ERROR | E_WARNING | E_PARSE ); \php_error\reportErrors( $options );
You can find more options here: https://github.com/JosephLenton/PHP-Error/wiki/Options.
WTF! Globals? Declaring parameters in the middle class?
To rewrite 😉
I don’t think it is possible to write even hundreds lines with no mistakes. Only if it is something really simple. An reporting really can help to find the issues faster and fix properly.
Too bad concrete5 has to mess with the error_reporting level.
As Rasmus will tell you, even if you suppress them, any error/warnings slow PHP down…
We also need ~E_DEPRECATED because of adodb, but I agree, cleaning up these things would be nice!