2

So I set display_errors to "On" and error_reporting to E_ALL|E_STRICT and 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?

0

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

Comments

1
  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!

3 Comments

1. sorry, I thought you are setting it in php.ini 2. look to first pint 3. look to first point 4. you told it's E_ALL|E_STRICT - are you sure your provider does allow ini_set(); ?
I am my own provider, so to say. ini_set and the settings alls show an effect, though not my desired one - there's my question aiming at. The pipe | indicates a bitwise OR and makes PHP report E_ALL and E_STRICT (which isn't covered by E_ALL, surprise, surprise)
and why donť you try to set it in php.ini instead of in php script ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.