|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-06 16:56 UTC] judas dot iscariote at gmail dot com
[2007-01-22 01:20 UTC] didou@php.net
[2009-09-02 14:08 UTC] mez@php.net
[2009-10-09 22:45 UTC] svn@php.net
[2009-10-09 22:47 UTC] mez@php.net
[2020-02-07 06:10 UTC] phpdocbot@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 18:00:02 2025 UTC |
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