Re: is_a() vs. instanceof
| From: | Dan Ostrowski | Date: | Thu, 12 Aug 2004 03:19:55 +0000 |
| Subject: | Re: is_a() vs. instanceof | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-12098@lists.php.net to get a copy of this message | ||
On Tuesday 10 August 2004 7:36 pm, Hans Lellelid wrote:
> I like the new $obj instanceof ClassName way of checking class /
> interface types, .... but this method does have one major drawback
> compared to the old is_a() approach:
>
> The class must be loaded in order to perform an instanceof check!
>
Isn't that the point? is_a() and instanceof are ways of checking the class of
an object at runtime where it could be any number of things. ( And here I'm
assuming you mean instantiated instead of "loaded"? )
If you don't have an instantiated object.. what do you have? A class! And THAT
can be checked at "compile" ( or in this case write ) time. There's something
wrong with my code, if I'm thinking of this right, if I have no idea if class
A is a subclass of class B.
Now, if I'm passed random objects, I may want to know of which types they
are... which is where these functions/builtins come in...
Am I misunderstanding you?
Dan Ostrowski