开发者

How to have Apache output really ALL errors?

So I set display_errors to "On" and error_reporting to E_ALL|E_STRICT and开发者_如何学JAVA even display_startup_errors shall be "On".

Yet, Apache will give me a blank page if I forget a $ or a ).

On CLI though I get a message.

How have that message displayed?


As your comment discussion hints, the problem is that you're trying to set it in your script.

In order to run a script, the PHP interpreter must first parse that script. If the parsing fails (ie: there is a syntax error), the script is invalid, and the interpreter doesn't run it at all -- it emits a fatal error.

So, a syntax error is a compile-time error, not a run-time error.

So, if you forget a $, ), or ;, for example, your script has invalid syntax. Therefore the script is not run. Therefore your ini_set() and similar statements are never run.

The interpreter simply doesn't get that far.

The only way to get those errors to output is to set those variable before the interpreter tries to parse your broken script, ie: in php.ini (or perhaps in .htaccess if you're running under mod_php). That way, the error reporting configuration is set before the interpreter attempts to parse your broken script.


When PHP runs your script, it goes through basically three steps (this is simplified):

1) Parse the script -- it scans through the whole script top to bottom, and creates a representation of it. If you made a syntax error, it fails to parse, and emits a fatal error, and stops.

2) Compiles the script -- it takes the output of step one, and turns it into machine code.

3) Runs the script -- it runs that machine code, which is your script, starting essentially at line 1.

The problem you're having is that during step 1 (parsing), PHP has not yet run ANY of your code (it doesn't, until step 3). So the settings it's running under are the default ones from PHP ini -- what you'd see if you wrote a one-line script with only a single phpinfo() call in it.


  1. This belongs to serverFault
  2. are you sure you restarted apache?
  3. are you sure you edited correct php.ini file?
  4. try error_reporting set to E_ALL

These suggestions/points should be done if you're editing server configuration, because you can't handle parse error in php script!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜