Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12101 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95558 invoked by uid 1010); 12 Aug 2004 03:52:34 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 95354 invoked from network); 12 Aug 2004 03:52:33 -0000 Received: from unknown (HELO lakermmtao12.cox.net) (68.230.240.27) by pb1.pair.com with SMTP; 12 Aug 2004 03:52:33 -0000 Received: from [192.168.3.100] (really [68.98.128.109]) by lakermmtao12.cox.net (InterMail vM.6.01.03.02.01 201-2131-111-104-103-20040709) with ESMTP id <20040812035230.TOTZ14787.lakermmtao12.cox.net@[192.168.3.100]>; Wed, 11 Aug 2004 23:52:30 -0400 Message-ID: <411AE970.2080908@velum.net> Date: Wed, 11 Aug 2004 23:52:16 -0400 User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 CC: Dan Ostrowski , internals@lists.php.net References: <41196A1D.6060808@velum.net> <200408112219.55268.dan@ostrowski.cc> <411AE454.4060808@akbkhome.com> In-Reply-To: <411AE454.4060808@akbkhome.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] is_a() vs. instanceof From: hans@velum.net (Hans Lellelid) 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