Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm looking for a functionality, in the example below called "theFunctionILookFor", that will make the code work.

$myClassName = "someName";
$parentOrInterfaceName = "someParent";
if (theFunctionILookFor($myClassName)) {
    echo "is parent";
}

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

question from:https://stackoverflow.com/questions/4618550/instanceof-equivalent-for-a-string-represented-classname

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
452 views
Welcome To Ask or Share your Answers For Others

1 Answer

Looks like this is my answer: is_subclass_of

It can accept both parameters as strings

http://php.net/manual/en/function.is-subclass-of.php


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...