开发者

Set_error_handler with static-method callback

开发者 https://www.devze.com 2023-02-06 19:21 出处:网络
I RTM but I couldn\'t find any nice answer to this question, so here is it: Can I call a static method as an error handler (for example: set_error_handler(开发者_StackOverflow中文版\'error::function

I RTM but I couldn't find any nice answer to this question, so here is it:


set_error_handler expects a value of the pseudo-type callback. And in the examples there you can see that there are two ways to specify a static method:

set_error_handler(array('Class', 'method'));

// since PHP 5.2.3
set_error_handler('Class::method');


Yes; this syntax works:

set_error_handler('error::function');

As stated in the doc, you just have to pass a valid callback. http://php.net/manual/en/language.pseudo-types.php#language.types.callback(dead link)

0

精彩评论

暂无评论...
验证码 换一张
取 消