call_user_func_Arrayの使い方

782 ワード

call_user_func_array(callback$function,array$param_arr)パラメータ1:ユーザー定義の関数またはクラス内のメソッドを呼び出す.パラメータ2:渡されたパラメータの戻り値:メソッド実行の結果例:
<?php
function foobar($arg, $arg2) {
    echo __FUNCTION__, " got $arg and $arg2
"; } class foo { function bar($arg, $arg2) { echo __METHOD__, " got $arg and $arg2
"; } } // foobar , call_user_func_array("foobar", array("one", "two")); // : foobar got one and two // foo bar , $foo = new foo; // call_user_func_array(array($foo, "bar"), array("three", "four")); // :foo::bar got three and four ?>