function foobar($arg, $arg2) { echo __FUNCTION__, " got $arg and $arg2/n";}html' target='_blank'>class foo { function bar($arg, $arg2) { echo __METHOD__, " got $arg and $arg2/n"; }}// 普通函数调用call_user_func_array("foobar", array("one", "two"));// 类成员函数调用$foo = new foo;call_user_func_array(array($foo, "bar"), array("three", "four"));
call_user_func(function($arg) { print "[$arg]/n"; }, 'test');
$newfunc = create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');echo "New anonymous function: $newfunc/n";echo $newfunc(2, M_E) . "/n";
<?phpfunction sum() { $acc = 0; foreach (func_get_args() as $n) { $acc += $n; } return $acc;}echo sum(1, 2, 3, 4);?>
检测函数是否存在
function_?exists("函数名"); // 检测一个函数是否存在Array( [internal] => Array ( [0] => zend_version [1] => func_num_args [2] => func_get_arg [3] => func_get_args [4] => strlen [5] => strcmp [6] => strncmp ... [750] => bcscale [751] => bccomp ) [user] => Array ( [0] => myrow ))
function add(){ code here... } register_?shutdown_?function("add");
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。
新闻热点
疑难解答