php call_user_func和,php – call_user_func()和$var()之间有区别吗?
生活随笔
收集整理的這篇文章主要介紹了
php call_user_func和,php – call_user_func()和$var()之间有区别吗?
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
call_user_func()和它的語法糖版本之間是否有任何區(qū)別……
// Global function
$a = 'max';
echo call_user_func($a, 1, 2); // 2
echo $a(1, 2); // 2
// Class method
class A {
public function b() {
return __CLASS__;
}
static function c() {
return 'I am static!';
}
}
$a = new A;
$b = 'b';
echo call_user_func(array($a, $b)); // A
echo $a->$b(); // A
// Static class method
$c = 'c';
echo call_user_func(array('A', $c)); // I am static!
echo a::$c(); // I am static!
兩者輸出相同,但我是recently hinted(僅10k rep),它們不相同.
那么,差異是什么呢?
總結(jié)
以上是生活随笔為你收集整理的php call_user_func和,php – call_user_func()和$var()之间有区别吗?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python 中文字符串截取,Pytho
- 下一篇: php mysql不大小写吗,PHP+M