Display PHP errors while removing all other content
On the development server, a setting was changed here that causes any PHP error (of any level) to output an error message and nothing else. To demonstrate what I mean, here's a script to reproduce the error:
<?php
$array = array('a');
echo "Hello world";
echo $array[1];
echo $array[2];
echo "Goodbye world";
?>
What I expect from this is "Hello world" and then two PHP notifications that say there is an undefined offset in the array and then "Goodbye world". I can actually see this:
PHP Notice: Undefined offset: 1 in /path/to/myfile.php on line 4
PHP Notice: Undefined offset: 2 in /path/to/myfile.php on line 5
... and nothing else. (Also note that this is in plain text, not HTML). Of course I could install error_reporting(0)
, but then I don't see any errors.
Does anyone know what PHP settings will control this?
source to share
You need to turn off warnings and just get fatal errors. This should do the following:
error_reporting (E_ERROR | E_WARNING | E_PARSE);
or that:
error_reporting (E_ERROR | E_PARSE);
the error reporting method here accepts an integer and the pipe character is bitwise or concatenates their base integer values ββto achieve the final integer passed to the function.
source to share