I’m looking to run a bit of custom error handling for PHP’s parse errors – the type when the syntax is wrong, and you get those white screens of death.
(To be clear, the type that would result when running malformed code as so:
<?php if () { ?>
)
I had a look at setting a custom error handler, but couldn’t get anything to happen.
Another idea: If you have an own root server or just want to execute the script on your local PC you could do the following:
Put the code to test in a new file, say
failure.php. In your script (same directory), where you want to check for errors, do it this way:Then you have the parse error messages in
$result, because the flag-lmakes PHP only parse the code. It will never execute anything. You can parse the error messages if any on your own and even get the line numbers out of them.