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?

+2


source to share


2 answers


I am assuming output buffering is enabled. Try:



<?php
$array = array('a');
echo "Hello world";
ob_flush();
echo $array[1];
echo $array[2];
echo "Goodbye world";
?>

      

+1


source


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.

http://74.125.155.132/search?q=cache:QvgitR0nX34J:php.net/manual/en/function.error-reporting.php+php+fatal+error+reporting&cd=1&hl=en&ct=clnk&gl=us

0


source







All Articles