From: gk at proliberty dot com Operating system: linux RH 7.2; kernel 2.4.18 PHP version: 4.3.2RC1 PHP Bug Type: CGI related Bug description: Fatal errors fails exit with status=0
According to the manual, require() differs from include() in that failure to open a file is FATAL in require(). Yet, using sapi/cgi/php or sapi/cli/php, fatal errors from require() exit with status=0 instead of non-zero, as one would expect from a 'fatal' error. I do not know if this problem is true for ALL fatal errors or not. Calling exit(1) works correctly however, which provides an awkward, but useful, workaround to this problem: $success=require("non_existent.php"); if (!$success) exit(1); Here is my test file: /htdocs/common/test/junk/test.php <?php $script="non_existent_file"; $success=require_once($script); //the following fixes the problem: //if (!$success) exit(1); ?> [EMAIL PROTECTED] sapi]# cli/php -f /htdocs/common/test/junk/test.php; echo status="$?"; Warning: main(non_existent_file) [http://www.php.net/function.main]: failed to open stream: No such file or directory in /usr/local/apache/htdocs/common/test/junk/test.php on line 4 Fatal error: main() [http://www.php.net/function.require]: Failed opening required 'non_existent_file' (include_path='.:/usr/local/apache/htdocs/common/php:/usr/local/lib/php') in /usr/local/apache/htdocs/common/test/junk/test.php on line 4 status=0 [EMAIL PROTECTED] sapi]# cli/php -r 'exit(1);'; echo status="$?"; status=1 [EMAIL PROTECTED] sapi]# -- Edit bug report at http://bugs.php.net/?id=22775&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=22775&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=22775&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=22775&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=22775&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=22775&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=22775&r=support Expected behavior: http://bugs.php.net/fix.php?id=22775&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=22775&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=22775&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=22775&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22775&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=22775&r=dst IIS Stability: http://bugs.php.net/fix.php?id=22775&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=22775&r=gnused