问题
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