|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-08-11 06:35 UTC] tater at potatoe dot com
Description:
------------
Throwing an exception from a function called by call_user_func() causes a warning to be issued,
saying it was unable to call the function.
An odd side note: if I set up my own error handler,
it does not receive this warning. Kind of an
inadvertant workaround for now...
Reproduce code:
---------------
function bar($x='no argument')
{
throw new Exception("This is an exception from bar({$x}).");
}
try { bar('first try'); }
catch (Exception $e) { print "{$e->message}\n"; }
try { call_user_func('bar','second try'); }
catch (Exception $e) { print "{$e->message}\n"; }
Expected result:
----------------
This is an exception from bar(first try).
This is an exception from bar(second try).
Actual result:
--------------
This is an exception from bar(first try).
Warning: call_user_func(bar): Unable to call bar(second try) in /my/pathname/test.php on line 8
This is an exception from bar(second try).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
The Exception class seems to have changed since this bug was logged. So here is a new test case for you. function bar($x='no argument') { throw new Exception("This is an exception from bar({$x})."); } try { bar('first try'); } catch (Exception $e) { print "{$e->getMessage()}\n"; } try { call_user_func('bar','second try'); } catch (Exception $e) { print "{$e->getMessage()}\n"; } Same results.