Reply to Re: is_a() against instanceof

Your name:

Reply:


Posted by Christian Stadler on 03/20/05 23:04

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jason Barnett schrieb:
> Nice suggestion! But I wonder... would it perhaps be better to use the
> && operator instead of the AND operator? That way in case you are
> trying to do an assignment PHP won't bother to check instanceof if the
> class_exists() fails.
>
> if (class_exists($class) && $cls instanceof $class)
> {
>
> }

mmh ... instanceof isn't listed at
http://www.php.net/manual/en/language.operators.php#language.operators.precedence
so I'm not 100% sure. But neither
php -r "var_dump(class_exists('foobar') AND $a instanceof foobar);"
nor
php -r "var_dump(class_exists('foobar') AND ($a instanceof foobar));"
triggered an error on the commandline. So I guess, both && and AND
should work.

Regards,
Christian Stadler
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCPeVQ9250Hcbf/3IRAg6rAJ96A/iBzkDU1X3cCOFWo/waV1y3ywCfSbIF
S4JU3lo66WnPw5y8q3qMVSU=
=bRQK
-----END PGP SIGNATURE-----

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация