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 08, 2005 @ 11:17:22

On his blog today, Pierre has a little something that he's noticed when using instanceof in his OOP programming - a fatal error that's thrown.

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).

He notes that if you'd like to make a comment to try to support a change to the next release to make it work corretly, you can reply to his post on the phpdev mailing list, and that he has been working on a patch to correct the problem...

tagged:

Link:


Trending Topics: