[英]“unexpected T_PAAMAYIM_NEKUDOTAYIM” on one computer but not another with PHP 5
My local computer runs PHP 5.3.2, while my server runs 5.2.5. 我的本地计算机运行PHP 5.3.2,而我的服务器运行5.2.5。 I get
我懂了
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM
with 与
$productsIterator = $productModule::load(Phlex_Db_Order::Asc('name'));
I assume the error happens because PHP 5.2.5 doesn't support $stringClassName::methodName() syntax. 我认为发生错误是因为PHP 5.2.5不支持$ stringClassName :: methodName()语法。
Does anyone know either 1) a workaround or 2) some other reason this is happening? 有人知道1)解决方法或2)发生这种情况的其他原因吗?
One workaround will be 一种解决方法是
call_user_func(array($productModule, "load"), Phlex_Db_Order::Asc('name'));
or, according to the manual since 5.2.3: 或者,根据5.2.3以后的手册:
call_user_func($productModule."::load", Phlex_Db_Order::Asc('name'));
Only one thing to note: 只有一件事要注意:
the parameters for call_user_func() are not passed by reference.
call_user_func()的参数未通过引用传递。
And for completeness' sake, you are right, "dynamic" calling of static methods was added in 5.3.0. 出于完整性考虑,您是对的,在5.3.0中添加了对静态方法的“动态”调用。 From the PHP 5 change log :
从PHP 5更改日志 :
Added support for dynamic access of static members using
$foo::myFunc()
.添加了对使用
$foo::myFunc()
的静态成员的动态访问的支持。 (Etienne Kneuss)(Etienne Kneuss)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.