call_user_func和call_user_func_array
call_user_func函数类似于一种特别的调用函数的方法,使用方法如下:
<?php
function a($b,$c)
{
echo $b;
echo $c;
}
call_user_func(‘a’, “111″,”222″);
call_user_func(‘a’, “333″,”444″);
//显示 111 222 333 444
?>
调用类内部的方法比较奇怪,居然用的是array,不知道开发者是如何考虑的,当然省去了new,也是满有新意的:
<?php
class a {
function b($c)
{
echo $c;
}
}
call_user_func(array(“a”, “b”),”111″);
//显示 111
?>
call_user_func_array函数和call_user_func很相似,只不过是换了一种方式传递了参数,让参数的结构更清晰:
<?php
function a($b, $c)
{
echo $b;
echo $c;
}
call_user_func_array(‘a’, array(“111″, “222″));
//显示 111 222
?>
call_user_func函数和call_user_func_array函数都支持引用,这让他们和普通的函数调用更趋于功能一致:
<?php
function a(&$b)
{
$b++;
}
$c = 0;
call_user_func(‘a’, &$c);
echo $c;//显示 1
call_user_func_array(‘a’, array(&$c));
echo $c;//显示 2
?>
You and I think alike.
Thanks for a great post.
this year is G.O.O.D
I was wondering the same thing.
i hope so
thanks for the info.like it.
It sounds like you are on the right track.
Thank you.Goddess of 2010. Let’s make this a positively, loving year.
Cheers to you….I look forward to reading more of your work. What a gem you are.
Cute Hope!!
thanks you on this blog that writes very wise and loving thoughts.
this blog is better Ye
There is absolutely nothing that has not once been said or done
Love to see this I saw the Inspriation
Wow, well done.