Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

::class equivalent in PHP 5.4

Tags:

php

php-5.4

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?

like image 308
Ben Cook Avatar asked Oct 31 '22 19:10

Ben Cook


1 Answers

See if this does it for you:

$class = __NAMESPACE__ ."\\".get_class($connection_object);
like image 163
Kevin_Kinsey Avatar answered Nov 12 '22 03:11

Kevin_Kinsey