On 19/03/2012, at 6:32 AM, Tim Streater wrote:

> After recently omitting a semicolon from the end of a statement, and having 
> the result be a JavaScript error in an odd place, I'm trying to pin down just 
> what PHP does with such errors. I made a small test script to run at CLI, 
> which does some echoes and then, after that, I miss out a semicolon. On the 
> command line, all I get is the parse error message with line number.
> The script where I'd left the semicolon out of my production code is reached 
> via AJAX, and sends some results back. It consists of a number of functions, 
> then the main code appears, starting with two requires. The first such 
> included file has some functions, puts out a header and does an echo, and 
> calls set_error_handler. It's in the second included file that the semicolon 
> is missed off (inside yet another function).
> I would have expected that the results sent back would just consist of the 
> Parse error: message, but for some reason the echo done in the first included 
> file shows up as well (this is important as it frames the parse error message 
> for me).
> Is this the expected behaviour? The doc for set_error_handler says you can't 
> use it to recover from E_PARSE and the like, and the function I supply to it 
> doesn't appear to be called. I was just surprised that the initial echo 
> statement's output made it back to the JavaScript side.
> (I obviously don't expect to have parse errors show up in production, but 
> having them nicely visible and logged during testing is useful)
> --
> Cheers  --  Tim

This is expected. The error doesn't occur to the second file is included, so 
everything in the first included file is parsed and run before execution is 
Simon Welsh
Admin of http://simon.geek.nz/

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to