php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17734 CLI and CGI sapi return error code '0' (success) if file couldn't be parsed
Submitted: 2002-06-12 22:09 UTC Modified: 2002-09-15 18:03 UTC
From: mfischer@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0CVS-2002-06-12 OS: Any
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mfischer@php.net
New email:
PHP Version: OS:

 

 [2002-06-12 22:09 UTC] mfischer@php.net
$ cat test.php
<?
        happy_parser_error(
?>

$ php -v
PHP 4.3.0-dev (cli), Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.2.1, Copyright (c) 1998-2002 Zend Technologies

$ php -f test.php ; echo $?

Parse error: parse error, unexpected ';', expecting ')' in test.php on line 3
test.php(3) : Parse error - parse error, unexpected ';', expecting ')'
0

$ php-cgi -v
PHP 4.3.0-dev (cgi), Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.2.1, Copyright (c) 1998-2002 Zend Technologies

$ php-cgi -f test.php ; echo $?
<br />
<b>Parse error</b>:  parse error, unexpected ';', expecting ')' in <b>/home/mfischer/test.php</b> on line <b>3</b><br />
/home/mfischer/test.php(3) : Parse error - parse error, unexpected ';', expecting ')'
0

The CLI version seems to be right at first:

$ php -r 'happy_parser_error(' ; echo $?
Command line code(1) : Parse error - parse error, unexpected $, expecting ')'
254

But suffers the limitation that you can't change the exit status:
$ php -r 'exit(2);' ; echo $?
255

(This is open in http://bugs.php.net/?id=17733&edit=1 , just mentioning here).

Needs to be fixed before 4.3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-13 05:45 UTC] edink@php.net
The trouble is that zend_execute_scripts() treats exit() as an error condition. So we can either detect parse errors, or have correct exit_code.

So zend needs to be fixed either to:

1. set EG(exit_code)=255 on parse and other critical errors
or
2. return SUCCESS even after call to exit()

 [2002-06-13 09:30 UTC] sniper@php.net
So it's another Zend buggie. :)

 [2002-09-15 18:03 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 20:00:02 2026 UTC