Question

Here is my code:

echo 'foo';

error_reporting(E_ALL);

echo 'this line doesnt end in a semi colon'

echo 'i should get an error here';

When I run this I get no error.

Not sure how this can be?

Was it helpful?

Solution

ini_set('display_errors', 1);

Do note though that if you do this in the file that has the syntax error, it won't work, as it'll never get executed then. You can also set this true in php.ini (not recommended for production servers), or if you use Apache, in .htaccess with:

php_flag display_errors 1

OTHER TIPS

error_reporting directive won't help you to show error messages on-screen. It's responsible for which error to show, not where.

if your PHP runs as Apache module (most likely it does) add the following line into .htaccess file:

php_value display_errors 1

when you switch to production, change it to

php_value display_errors 0
php_value log_errors 1

and watch them it in the error log.

Do you have any kind of shutdown hooks, error-handling functions or global exception catchers running?

Syntax errors can be quirky in large frameworks :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top