Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3952 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24653 invoked from network); 14 Aug 2003 19:17:53 -0000 Received: from unknown (HELO pd2mo2so.prod.shaw.ca) (24.71.223.10) by pb1.pair.com with SMTP; 14 Aug 2003 19:17:53 -0000 Received: from pd3mr1so.prod.shaw.ca (pd3mr1so-ser.prod.shaw.ca [10.0.141.177]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HJM00JGMIXTGU@l-daemon> for internals@lists.php.net; Thu, 14 Aug 2003 13:17:53 -0600 (MDT) Received: from pn2ml6so.prod.shaw.ca (pn2ml6so-qfe0.prod.shaw.ca [10.0.121.150]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HJM00GUZIXT1H@l-daemon> for internals@lists.php.net; Thu, 14 Aug 2003 13:17:53 -0600 (MDT) Received: from h24-84-221-8.vc.shawcable.net (h24-84-221-8.vc.shawcable.net [24.84.221.8]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HJM00JM4IXSFB@l-daemon> for internals@lists.php.net; Thu, 14 Aug 2003 13:17:53 -0600 (MDT) Date: Thu, 14 Aug 2003 12:17:20 -0700 In-reply-to: <200308141145.38495.ilia@prohost.org> To: ilia@prohost.org Cc: internals@lists.php.net Message-ID: <1060888639.1036.28.camel@ali> Organization: MIME-version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Content-type: text/plain Content-transfer-encoding: 7BIT References: <1060813541.901.336.camel@ali> <200308141145.38495.ilia@prohost.org> Subject: Re: [PHP-DEV] variable_exists() patch From: torben@php.net (Lars Torben Wilson) On Thu, 2003-08-14 at 08:45, Ilia Alshanetsky wrote: > Do we really need this function? I see 2 ways of 'implementing' this > functionality in PHP without having to add another function. For example: > (isset($var) || is_null($var)) or gettype($var). > > Ilia Those ideas don't do the same thing, though. Try it with arrays: -SNIP------------------------------------------------------------ >>>> Array testing with variable_exists() $arr = array(1 => null, 2 => array(1 => 3, 2 => null)); variable_exists($arr[1]): yes (should be yes) variable_exists($arr[2]): yes (should be yes) variable_exists($arr[3]): no (should be no) variable_exists($arr[1][2]): no (should be no) variable_exists($arr[2][1]): yes (should be yes) variable_exists($arr[2][2]): yes (should be yes) variable_exists($arr[2][3]): no (should be no) >>>> Array testing with gettype() $arr = array(1 => null, 2 => array(1 => 3, 2 => null)); gettype($arr[1]): yes (should be yes) gettype($arr[2]): yes (should be yes) Notice: Undefined offset: 3 in /home/torben/public_html/phptest/variable_exists.html on line 40 gettype($arr[3]): yes (should be no) gettype($arr[1][2]): yes (should be no) gettype($arr[2][1]): yes (should be yes) gettype($arr[2][2]): yes (should be yes) Notice: Undefined offset: 3 in /home/torben/public_html/phptest/variable_exists.html on line 44 gettype($arr[2][3]): yes (should be no) >>>> Array testing with (isset() || is_null()) $arr = array(1 => null, 2 => array(1 => 3, 2 => null)); (isset($arr[1]) || is_null($arr[1])): yes (should be yes) (isset($arr[2]) || is_null($arr[2])): yes (should be yes) Notice: Undefined offset: 3 in /home/torben/public_html/phptest/variable_exists.html on line 51 (isset($arr[3]) || is_null($arr[3])): yes (should be no) (isset($arr[1][2]) || is_null($arr[1][2])): yes (should be no) (isset($arr[2][1]) || is_null($arr[2][1])): yes (should be yes) (isset($arr[2][2]) || is_null($arr[2][2])): yes (should be yes) Notice: Undefined offset: 3 in /home/torben/public_html/phptest/variable_exists.html on line 55 (isset($arr[2][3]) || is_null($arr[2][3])): yes (should be no) -SNIP------------------------------------------------------------ -- Torben Wilson +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----