What about: if (get_class($obj) == "unloadedclass") { // blah }
Jevon ----- Original Message ----- From: "Al Baker" <[EMAIL PROTECTED]> To: "Hans Lellelid" <[EMAIL PROTECTED]> Cc: "Dan Ostrowski" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, August 12, 2004 9:58 PM Subject: Re: [PHP-DEV] is_a() vs. instanceof > I agree, that's the exact behavior I would like as well and what most > people would expect. > > Al > > On Wed, 2004-08-11 at 23:52 -0400, Hans Lellelid wrote: > > Alan Knowles wrote: > > > > > I think he's referening to something like this (which is common in pear): > > > > > > $x = $someobj->somemethod(); > > > if ($x instanceOf PEAR_Error) { > > > ....... > > > } > > > > > > while that code is redundant in the case of exceptions, it is still a > > > valid situation.. that $x may be a valid return, and PEAR_Error was > > > never loaded.. > > > > > > Yup, that's exactly what I'm talking about. > > > > I want to be able to do this: > > > > if ($db instanceof DBPostgres) { > > /// do something funky specific to Postgres > > } > > > > If My DB adapter is DBMySQL, I don't want to load the DBPostgres adapter > > just so I can test whether my object is of that type ... > > > > and checking first whether class_exists('DBPostgres') just seems kinda > > kludgy & straying from the "problem domain" ... especially since $db > > instanceof DBPostgres would *always* be false if DBPostgres isn't loaded. > > > > Hans > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php