|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-07-26 00:23 UTC] yohgaki@php.net
-Status: Open
+Status: Not a bug
[2013-07-26 00:23 UTC] yohgaki@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 13:00:01 2025 UTC |
Description: ------------ My code converts errors to exceptions, but it turned out that when faced with "Failed opening required 'whatever'" error, exception handler doesn't get called. More precisely, it doesn't work for require, but works for include. I tested it on debian 6.0.6 (php-5.4.15), on arch linux (php-5.4.17) and on windows 7 (php-5.4.17). Test script: --------------- #!/usr/bin/env php <?php set_error_handler(function() { echo "error\n"; throw new Exception; }); set_exception_handler(function() { echo "exception\n"; }); require 'asdf'; Expected result: ---------------- error exception Actual result: -------------- error PHP Warning: Uncaught exception 'Exception' in /home/yuri/1.php:6 Stack trace: #0 /home/yuri/1.php(11): {closure}(2, 'require(asdf): ...', '/home/yuri/1.ph...', 11, Array) #1 /home/yuri/1.php(11): require() #2 {main} thrown in /home/yuri/1.php on line 6 PHP Fatal error: main(): Failed opening required 'asdf' (include_path='.:/usr/share/php:/usr/share/pear') in /home/yuri/1.php on line 11