Re: require_once and E_WARNING?
| From: | Chris | Date: | Thu, 06 Jul 2006 04:32:55 +0000 |
| Subject: | Re: require_once and E_WARNING? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-239156@lists.php.net to get a copy of this message | ||
php@kermodebear.org wrote:
Hello all, According to the PHP Manual, when require or require_once failes, an E_ERROR is triggered: "require() and include() are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error." (With 'Fatal Error' being a link to E_ERROR). Thing is, when using a custom error handler via set_error_handler(), it appears to be triggering an E_WARNING, not an E_ERROR. Using PHP 5.1.4 under Linux. There are one of three possibilities: I am suffering from a lapse in lucidity (common), the manual is wrong (possible), or PHP is broken somehow (unlikely). I'm guessing it's the first, but what am I doing wrong? I'd like to get a second opinion before submitting a bug. I searched bugs.php.net but was unable to find anything relevant for 5.1.4. Code: function default_error_handler($code, $error, $file, $line) { switch ($code) { case E_ERROR:If you comment out the 'set_error_handler' line what happens? Do you get what you expect (and what should happen) ? It looks like a pretty simple bug report to me but others may have reasons why it's not working. -- Postgresql & php tutorials http://www.designmagick.com/die ("Error: $error");case E_WARNING:die("Warning: $error");default:die("Something else entirely: $error");} } set_error_handler('default_error_handler'); require('This file does not exist. At least not here!'); Result: Warning: require(This file does not exist. At least not here!) [function.require]: failed to open stream: No such file or directory Expected Result: Error: require(This file does not exist. At least not here!) [function.require]: failed to open stream: No such file or directory