From: kermode at kermodebear dot org Operating system: Ubuntu Linux PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: require() raises E_WARNING before E_ERROR
Description: ------------ It appears that the require and require_once functions raise an E_WARNING before raising an E_ERROR. This is inconsistent with the documentation which implies that only an E_ERROR is raised when require fails. "The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error." Code below tested with PHP versions 4.4.2 on RedHat Linux and 5.1.4 on Ubuntu Linux. Same result. Reproduce code: --------------- function default_error_handler($code, $error, $file, $line) { switch ($code) { case E_WARNING: echo "Warning: $error"; break; default: echo "Something Else: $error"; } } set_error_handler('default_error_handler'); require('This file does not exist. At least not here!'); Expected result: ---------------- Fatal error: require(): Failed opening required 'This file does not exist. At least not here!' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/kermode/test.php on line 12 Actual result: -------------- Warning: require(This file does not exist. At least not here!): failed to open stream: No such file or directory Fatal error: require(): Failed opening required 'This file does not exist. At least not here!' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/kermode/test.php on line 12 -- Edit bug report at http://bugs.php.net/?id=38024&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38024&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38024&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38024&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38024&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38024&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38024&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38024&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38024&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38024&r=support Expected behavior: http://bugs.php.net/fix.php?id=38024&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38024&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38024&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38024&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38024&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38024&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38024&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38024&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38024&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38024&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38024&r=mysqlcfg