|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #24135 eval() documentation ignores FALSE return value from Fatal Errors
Submitted: 2003-06-11 14:38 UTC Modified: 2004-08-07 12:12 UTC
From: gk at proliberty dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.2 OS: linux ; kernel 2.4.18
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: gk at proliberty dot com
New email:
PHP Version: OS:


 [2003-06-11 14:38 UTC] gk at proliberty dot com
The manual says:
> In PHP 4, eval() returns NULL unless return() is called in the evaluated code...

This is not true. PHP returns FALSE if a fatal error occurs.

This is very important especially for CLI/SAPI applications which must often catch fatal errors and propogate them with exit(1).

Reproduce code:
// FILE: test/test.php
echo "Non-Fatal Error Returns: ";
if($x===FALSE) echo "FALSE\n";
if(is_null($x)) echo "NULL\n";
echo "Fatal Error Returns: ";
if($x===FALSE) echo "FALSE\n";
if(is_null($x)) echo "NULL\n";

Expected result:
$ php test/test.php 
Non-Fatal Error Returns: NULL
PHP Parse error:  parse error in /usr/local/apache/htdocs/common/php/xmake_org/xobj/test/test.php(6) : eval()'d code on line 1
Fatal Error Returns: FALSE


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-07 12:12 UTC]
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"In case of fatal error in evaluated code, eval returns FALSE."
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 04:05:46 2022 UTC