本文共 1639 字,大约阅读时间需要 5 分钟。
call_user_func:把第一个参数作为回调函数调用。
call_user_func_array:调用回调函数,并把一个数组参数作为回调函数的参数。
func_get_arg:返回参数列表的某一项。参数的偏移量从0开始计算。
func_get_args:返回一个包含函数参数列表的数组。
func_num_args:返回传递给函数的参数个数。
0){ $last_arg=func_get_arg($num_args-1); echo "last argument is $last_arg\n"; echo "all arguments are ".join(",",func_get_args()); }else{ echo "no argument passed\n"; } }foo('a','b','c');foo();?>
forward_static_call:用提供的参数调用静态方法,不能在类外调用此函数。
forward_static_call_array:调用静态方法,并把一个数组参数作为回调函数的参数。
0){ $last_arg=func_get_arg($num_args-1); echo "last argument is $last_arg\n"; echo "all arguments are ".join(",",func_get_args())."\n"; }else{ echo "no argument passed\n"; } } }class B{ function test(){ forward_static_call(array('A','foo'),'a','b','c'); forward_static_call_array(array('A','foo'),array('a','b','c')); }}$b=new B;$b->test();B::test();?>
create_function:从传递的参数中创建一个匿名函数,并返回它的唯一名称。
function_exists:在已经定义的函数列表(包括系统自带的函数和用户自定义的函数)中查找指定的函数,如果存在则返回true,对于include_once、echo等语法结构,会返回false。
get_defined_functions:返回所有已定义的函数的数组。PHP7.0.15、PHP7.1.1增加一个可选的参数,表示是否去除返回数组中被禁用的函数,默认为false。返回的数组包含两部分,一部分是内置函数,另一部分是用户定义的函数,可通键internal来访问系统内置函数,通过键user来访问用户自定义函数。返回的数组中不包括匿名函数。
register_shutdown_function:注册一个会在php中止时执行的函数,注册的回调函数会在脚本执行完成或exit函数被调用后执行。可以多次调用register_shutdown_function函数来注册多个函数,这些函数会按注册时的顺序依次被调用,如果被注册的函数内部调用了exit函数,则所有处理会被中止,并且注册的其他回调函数也不会被调用。
register_tick_function:注册每个要执行的函数。
unregister_tick_function:取消注册的每个时钟周期(ticks)要执行的函数。
0) { $a += 2; print $a."\n";}?>
0) { $a += 2; print $a."\n";}?>
转载地址:http://gykkb.baihongyu.com/