Why won't PHP 5.2.14 display any errors (even from the command line)?

Kev picture Kev · Sep 29, 2010 · Viewed 14.4k times · Source

I have PHP 5.2.10 and PHP 5.2.14 (x86 non-threadsafe Win32 builds) installed on a Windows 2008 R2 server and on Windows 7 64 bit.

For some reason PHP 5.2.14 refuses to show error messages.

Even when I set the following settings in php.ini I don't get any errors reported if I use 5.2.14:

error_reporting = E_ALL
display_errors = On

This happens even when running a test script from the command line using php.exe with a deliberate syntax error:

c:\php>php test.php

PHP is using the correct php.ini file because I can see my settings change when I run php.exe -i.

I also notice that php.exe in PHP 5.2.14 is very slow to start up.

When I perform the same set of tests using PHP 5.2.10 on the same machines I get error messages reported just fine.

Both of the php.ini files are stock (based off of php.ini-recommended) but with the error_reporting and display_errors settings modified.

Answer

Gunnarsson picture Gunnarsson · Sep 6, 2014

I have found this truly annoying, so here's a strategy for checking the syntax from the command line:

  1. Don't load the ini file.
  2. Turn on display_errors and display_startup_errors explicitly.

php -n -l -d display_errors -d display_startup_errors path/to/your/phpfile.php

$ php -h 
-n               No php.ini file will be used
-l               lint, syntax checking only
-d foo[=bar]     Define INI entry foo with value 'bar'