|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-06-30 21:29 UTC] thomas at thoftware dot de
Description:
------------
Setting an Errorhandler with set_error_handler() and then calling require() with a Function as Argument doesn't produce the expected Result.
Reproduce code:
---------------
function ehandler($e,$t,$f,$l,$c) {
echo $t;
}
function foo($foo) {
return($foo);
}
set_error_handler('ehandler');
error_reporting(E_ALL);
require_once(foo('foo'));
Expected result:
----------------
Some Errormessage like this:
main(foo) [function.main]: failed to open stream: No such file or directory
Fatal error: main() [function.require]: Failed opening required 'foo' (include_path='.;c:\php4\pear') in foo.php on line x
Actual result:
--------------
Nothing (infinite loop?). PHP crashes.
Using no Errorhandler or giving 'foo' directly to require_once() works.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 16 15:00:02 2025 UTC |
Something I found even earlier is: "The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.". Is that what you mean I should have read? Please note, that that isn't the problem. I don't want these error types to be handled. I simply want the whole construct to run and not to crash. The above script works fine in these 2 versions: Reproduce code 2 (works): --------------- function foo($foo) { return($foo); } error_reporting(E_ALL); require_once(foo('foo')); Reproduce code 3 (works): --------------- function ehandler($e,$t,$f,$l,$c) { echo $t; } set_error_handler('ehandler'); error_reporting(E_ALL); require_once('foo'); (Where 'fine' means, it shows the error an stops.) Can you pleeeeeeeeeease explain to me, why the first version crashes without any message?right, there's a problem with PHP 4 if foo does not exist, but I doubt anybody is going to fix it. Program received signal SIGSEGV, Segmentation fault. php_strip_url_passwd (url=0x0) at /home/johannes/src/php/PHP_4_4/main/fopen_wrappers.c:481 481 while (*p) { (gdb) bt #0 php_strip_url_passwd (url=0x0) at /home/johannes/src/php/PHP_4_4/main/fopen_wrappers.c:481 #1 0x080b46d8 in php_message_handler_for_zend (message=2, data=0x0) at /home/johannes/src/php/PHP_4_4/main/main.c:812 #2 0x080f22e1 in execute (op_array=0x8df088c) at /home/johannes/src/php/PHP_4_4/Zend/zend_execute.c:2240 #3 0x080df3ab in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/johannes/src/php/PHP_4_4/Zend/zend.c:935 #4 0x080b3805 in php_execute_script (primary_file=0xbf88fed0) at /home/johannes/src/php/PHP_4_4/main/main.c:1757 #5 0x080f9d39 in main (argc=1, argv=0xbf88ff94) at /home/johannes/src/php/PHP_4_4/sapi/cli/php_cli.c:838