开发者

Global "method_missing" in PHP? [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

Magic functions __call() for functions?

I can implement __call() to provide method_missing behavior in PHP classes. Is there some way to provide the same functionality in the global scope?

I want something like this:

function __call( $name, $arguments ) {
  echo( sprintf( '%s called', $name ) );
}

echo( 'before' );
call_开发者_JAVA百科undefined_function( $a, $b );
echo( 'after' );

Outputs:

before
call_undefined_function called
after


You can write your own error handler and use function_exists() in it to generate the message you want. As long as you don´t stop your script in your error handler, execution will continue.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜