Not displaying PHP errors

beetree picture beetree · Oct 5, 2011 · Viewed 34.2k times · Source

I've boiled down the problem and made it clean so that it hopefully will be easier for you to help me.

I have a very simple code:

<?php
echo "Hello world";
?>

This runs perfectly fine.

If I run the following code (parse error) I do not get any errors but the text "Hello world" is still displayed:

<?php
echo "Hello world";
piwejfoiwjefoijwef
?>

If I place the parse error before the code it does however not display "Hello world":

<?php
piwejfoiwjefoijwef
echo "Hello world";
?>

When I print phpinfo (in the same file, same directory) I have the following settings: display_errors On display_startup_errors On error_reporting 1

If I try to also set the error reporting inside the script and run it with the following code I still do not get any errors or warning but the text "Hello world" is displayed:

<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE); ini_set('display_errors', '1');
echo "Hello world";
owieufpowiejf
?>

My php.ini file has the following values (and I have restarted Apache):

error_reporting = E_ERROR & ~E_DEPRECATED
display_errors = On
display_startup_errors = On

I am running Apache / PHP / MySQL on the Amazon AMI with on a 64-bit AWS EC2. I am not that knowledgeable with server configurations. The errors started when I transitioned to the Amazon server. Besides error reporting the server and Apache/PHP runs flawlessly.

Please guide me in what I can do to fix the problem.

Thanks!

Answer

Madara&#39;s Ghost picture Madara's Ghost · Oct 5, 2011

That is a notice.

error_reporting(E_ALL);

reveals it.

Code I used:

<?php

    error_reporting(E_ALL); ini_set('display_errors', '1');
    echo "Hello world";
    owieufpowiejf

?>

Output:

Hello world

Notice: Use of undefined constant owieufpowiejf - assumed 'owieufpowiejf' in /code/14B4LY on line 5

That's because it's not a parse error, it thinks of it as a constant and tried to parse it as a string. And placing a normal string is a valid statement.