call_user_func_array和call_user_func函数的用法
zccst转载
下面来和大家分享一下这个call_user_func_array和call_user_func函数的用法,另外附赠func_get_args()函数和func_num_args()函数,嘿嘿!!
1,call_user_func函数
call_user_func函数是当需要动态调用函数时,才使用的,这个函数有两种用法:
第一种是调用孤独的函数:
<!--?function otest1 ($a){ echo( '一个参数' );}function otest2 ( $a, $b){ echo( '二个参数' );}function otest3 ( $a ,$b,$c){ echo( '三个啦' );} function otest (){ $args = func_get_args(); $num = func_num_args(); call_user_func_array( 'otest'.$num, $args );}otest("11");otest("11","22");otest("11","22","33");?-->
呵呵~上面这个例子,还是你们自己运行一下,那样印象更加深刻~
转载地址:http://www.skygq.com/category/php/