::class equivalent in PHP 5.4

旧街凉风 提交于 2019-12-10 15:58:29

问题


I've got a PHP script with the following line:

$class = Connection::class;

This runs as expected on PHP 5.5 as explained here: http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class. However, it causes a syntax error in PHP 5.4.

Is there a simple way that I can rewrite this line to run in PHP 5.4?


回答1:


See if this does it for you:

$class = __NAMESPACE__ ."\\".get_class($connection_object);


来源:https://stackoverflow.com/questions/32525810/class-equivalent-in-php-5-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!