$GLOBALS['failed'] = "no";
set_error_handler(function($errno, $errstr) {
$GLOBALS['failed'] = "yes";
});
a_function_that_triggers_the_above_function();
echo $GLOBALS['failed']."\n"; # => "no"
這個匿名函數被觸發,我100%確定。爲什麼GLOBALS值沒有改變?爲什麼全局變量不是在匿名函數中設置的?
作品對我來說太。我們將不得不假設'a_function_that_triggers_an_error();未能完成它的邪惡任務。 – mario 2011-02-26 16:56:36