Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Pierre's Blog:
instanceof, fatal error?
Aug 22, 2005 @ 11:06:19

On Pierre's weblog today he has this quick post about an issue he's seeing with instanceof when defining classes in PHP.

Since the introduction of instanceof (which is a good thing, works well with the new OO apis), is_a is deprecated. It is obvious as its usage could be replaced by instanceof.

The problem is that it raises a fatal error if the tested class does not exist, making instanceof useless in sanity checks or other usages in unknown environment (compiled libs, libs used by a lot of people and have to be as safe as possible (no fatal error for instance).

Thanks to some quick thinking (and a patch) on his part, the problem has been corrected and works without the error message...

tagged:

Link:


Trending Topics: