In PHP there is two classes:
class parentTroll {...}
and class troll extends parentTroll {...}
And then there is an object $troll = new troll();
How to check $troll instanceof parentTroll
? This line returns false now.
Following example returns true:
class parentTroll {}
class troll extends parentTroll {}
$troll = new troll();
var_dump($troll instanceof parentTroll);
Output:
boolean true
You can also use ReflectionClass
:
var_dump((new ReflectionClass($troll))->getParentClass()->getName() == 'parentTroll');
The documentation disagrees
See http://www.php.net/manual/en/language.operators.type.php
And so does my testing of your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With