ID: 36896 Updated by: [EMAIL PROTECTED] Reported By: akorthaus at web dot de -Status: Open +Status: Closed Bug Type: Scripting Engine problem Operating System: Linux 2.4.32 (gentoo) PHP Version: 5.1.2 New Comment:
Fixed in CVS yesterday. Previous Comments: ------------------------------------------------------------------------ [2006-03-28 17:51:44] akorthaus at web dot de Description: ------------ The ErrorException class bundled with PHP 5.1 does not work with Warnings/Fatal Errors produced by include() and require(). Reproduce code: --------------- <?php function ErrorsToExceptions($severity, $message) { throw new ErrorException($message, 0, $severity); } set_error_handler('ErrorsToExceptions'); try { include('./DOES_NOT_EXIST'); } catch (Exception $e) { echo get_class($e) . " catched!\n" echo $e->getMessage(); } ?> Expected result: ---------------- should throw an ErrorException and display $e->getMessage(), and should NOT display a PHP Warning. Actual result: -------------- Warning: main(): Failed opening './DOES_NOT_EXIST' for inclusion (include_path='.:') in /home/akorthaus/test/exc4.php on line 16 ErrorException catched! include(./DOES_NOT_EXIST): failed to open stream: No such file or directory if I replace "include" with "require", I get: Fatal error: main(): Failed opening required './DOES_NOT_EXIST' (include_path='.:') in /home/akorthaus/test/exc4.php on line 14 if I replace "require" with "file_get_contents", I get: ErrorException catched! file_get_contents(./DOES_NOT_EXIST): failed to open stream: No such file or directory That's what I'd expect to see from include() and require() too (ErrorException also works with other Fatal Errors!). So include() seems to throw an ErrorException, but additionaly displays the PHP Warning, require only displays the PHP Fatal Error, and does not throw an Exception at all. Is this intended? Is it somewhere documented how ErrorException works or should be used? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36896&edit=1