views:

54

answers:

2

On a development server here, a setting has been changed which makes any PHP error (of any level) only output the 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'd expect from this is "Hello world", then two PHP Notices saying that there was an undefined offset in the array, and then "Goodbye world". What I actually see is 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 it's in plain text like that, not HTML). Of course, I could set error_reporting(0), but then I don't see any of the errors.

Does anyone know what PHP setting would control this?

+1  A: 

My guess is that output buffering has been turned on. Try:

<?php
$array = array('a');
echo "Hello world";
ob_flush();
echo $array[1];
echo $array[2];
echo "Goodbye world";
?>
cletus
nope - makes no difference to the output
nickf
A: 

You need to turn off the warnings, and just get the fatal errors. This should do that:

error_reporting(E_ERROR | E_WARNING | E_PARSE);

or this:

error_reporting(E_ERROR | E_PARSE);

the error reporting method is taking an integer here, and the pipe character is bitwise or-ing their underlying integer values together to achieve the final integer passed to the function.

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

David
As I said in the OP, fiddling with the `error_reporting` level means that I'll be able to see my output, but it won't tell me if there's any notices. I'd like to see the errors, but not have them hide everything else.
nickf
the errors are probably just breaking your html / css / javascript (ui output). fix the errors. why do you not want to fix them in the first place?
David