Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3949 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13990 invoked from network); 14 Aug 2003 19:02:48 -0000 Received: from unknown (HELO mail.3gstech.com) (216.239.132.110) by pb1.pair.com with SMTP; 14 Aug 2003 19:02:48 -0000 Received: from 3gstech.com (ip-209-172-92-41.us01.qualys.com [209.172.92.41]) by mail.3gstech.com (Postfix) with ESMTP id 2CF9E9E41A6; Thu, 14 Aug 2003 12:02:47 -0700 (PDT) Message-ID: <3F3BDC4A.20603@3gstech.com> Date: Thu, 14 Aug 2003 12:00:26 -0700 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stefan Walk Cc: internals@lists.php.net References: <1060813541.901.336.camel@ali> <200308141145.38495.ilia@prohost.org> <3F3BD1D7.70209@3gstech.com> <20030814182806.GA25430@prp0.prp.physik.tu-darmstadt.de> In-Reply-To: <20030814182806.GA25430@prp0.prp.physik.tu-darmstadt.de> Content-Type: multipart/alternative; boundary="------------030008040702070001070202" Subject: Re: [PHP-DEV] variable_exists() patch From: waboring@3gstech.com (walt boring) --------------030008040702070001070202 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Stefan Walk wrote: >On Thu, Aug 14, 2003 at 11:15:51AM -0700, walt boring wrote: > > >>I for one would like to see something like variable_exists(), as I am >>very annoyed with >>the logic of isset() returning false if the variable exists and has a >>value of null. >> >> >[snip] > > >> I for one would much rather do >> if ( variable_exists($var) ) {} versus >>if (isset($var) || is_null($var)) {} >> >> > >When do you need to do that? I can't think of many situations where it >would be neccessary to check if a variable really exists. > > It can happen quite easily. I always develop with full warnings/errors on. So if for example a var isn't set for whatever reason, then trying to access the variable will throw a php Notice. variable_exists() would prevent that, as does isset(). isset() would work for my example below, but it still is a 'broken' function in my opinion. if ($var) { // <-- you'll get a php notice on this line switch ($var) { ... } } versus doing if (variable_exists($var)) { //no php notices here switch($var) { ... } } --------------030008040702070001070202--