php.net |  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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gk at proliberty dot com
New email:
PHP Version: OS:

 

 [2003-06-11 14:38 UTC] gk at proliberty dot com
Description:
------------
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:
---------------
<?php
// FILE: test/test.php
$x=eval(";");
echo "Non-Fatal Error Returns: ";
if($x===FALSE) echo "FALSE\n";
if(is_null($x)) echo "NULL\n";
$x=eval("<?");
echo "Fatal Error Returns: ";
if($x===FALSE) echo "FALSE\n";
if(is_null($x)) echo "NULL\n";
?>





Expected result:
----------------
OUTPUT:
$ 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-07 12:12 UTC] vrana@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 18:01:29 2024 UTC