[Project_owners] syntax error in php?

Dimitar Angelov mitko at edabg.com
Sat May 30 08:19:53 PDT 2009


Eric Jung wrote:
> Thanks for the reply , Dimitar. Here are my results:
> 
>  
> 
>     If it is runtime error you may include at the beginning of php
>     script command to turn on error reporting and display errors like this:
>     ini_set("display_errors", 1);
>     error_reporting(E_ALL);
> 
> 
> This didn't do anything on mozdev.
>  
> 
>     Another combined scenario if you don't have php locally is to create
>     new sample test script which turn on error reporting and include
>     sript with problem.
>     Something like this. Create new php file my-test.php with the
>     following content:
>     <?php
>     ini_set("display_errors", 1);
>     error_reporting(E_ALL);
>     include("my-php-file.php");
> 
>  
> This worked; i.e., it shows the parse error and line number. I wonder 
> why it works with an include but not otherwise?
By default on mozdev configuration "display_errors" is off.
With lines ini_set("display_errors", 1); and  error_reporting(E_ALL);
display of errors is turned on.
Why first scenario don't work for you?
Before execute script php make syntax analyze and byte code generating 
and in case of success continue with code execution. And particular 
these are lines to turn on error reporting.
In case of syntax errors script is not executed and error is not 
reported because of default configuration error reporting off.
Why second scenario work?
my-test.php script is syntactically correct and it is executed normally 
to line of include problem script. This mean that lines which turn on 
error reporting are executed.
When php include problem script it make syntax check of it and if found 
error php display it because error reporting is on yet.

Except syntax error there are another errors which break script 
execution, for example call of undefined function, instantiating non 
existent class and so on. These errors are some kind of runtime errors 
i.e. in process of executing script.


I hope this clear situation for you.

Regards,

Dimitar Angelov

EDA Ltd.
mailto:mitko at edabg.com
http://www.edabg.com


More information about the Project_owners mailing list