3

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?

6
  • 1
    Am I the only person who prefers to just tail -f the error log? :-) Commented Sep 30, 2010 at 13:52
  • 2
    @prodigitalson depends on the site state. for developnemt I prefer on-screen Commented Sep 30, 2010 at 13:58
  • I get no error. means I get all 3 lines printed or I get a blank screen? Commented Sep 30, 2010 at 14:03
  • @Col. Shrapnel, I get a blank screen. I added php_flag dislay errors 1. Which at first didn't work. Then I added <Directory "/var/www/aquaplatinum">Order allow,deny Allow from all AllowOverride All </Directory> To my apache2.conf file and restarted apache and now the errors are showing. Commented Sep 30, 2010 at 14:07
  • @Col. Shrapnel: Yeah even for development i prefer the log... This is because I like E_ALL|E_STRICT but i dont want warning ouput fudging the xhtml. Plus, im normally running tail directly in an Eclipse as an external tool :-) Commented Sep 30, 2010 at 14:08

3 Answers 3

12
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
Sign up to request clarification or add additional context in comments.

2 Comments

so php_flag display_errors 1 should show all errors allways? (cause its not my case)
No, it only tells that errors are displayed at all. The error_reporting configuration value determines what errors are displayed.
2

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.

Comments

0

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

Syntax errors can be quirky in large frameworks :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.