Reputation: 282
I'm working on an old application now, and I want to use ::class
method, however, it's not available for PHP version 5.1.
My question is: What is the equivalent of
SomeClass::class
in PHP < 5.1
Edit: It seems there's no alternative method like I mentioned above. For a workaround, I did this:
public static $class = __CLASS__;
and im calling it like this:
SomeClass::$class
Upvotes: 0
Views: 78
Reputation: 15247
You can use get_class()
<?php
class A
{
}
$obj = new A();
echo get_class($obj) . PHP_EOL;
This outputs :
A
Upvotes: 3