shealtiel shealtiel - 1 year ago 105
PHP Question

PHP: instanceof equivalent for a string-represented classname

It's best to explain by an example.
I look for a function "theFunctionILookFor" that will make the code work.

$myClassName = "someName";
$parentOrInterfaceName = "someParent";
if ( theFunctionILookFor ($myClassName)) echo "is parrent";

edit: I try to avoid instantiating the class just to perform this check. I would like to be able to pass 2 string parameters to the checking function

Answer Source

Looks like this is my answer: is_subclass_of

It can accept both parameters as strings