Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43917 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95149 invoked from network); 12 May 2009 19:50:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2009 19:50:35 -0000 Authentication-Results: pb1.pair.com header.from=robert@interjinn.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=robert@interjinn.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain interjinn.com from 66.11.173.122 cause and error) X-PHP-List-Original-Sender: robert@interjinn.com X-Host-Fingerprint: 66.11.173.122 unknown Received: from [66.11.173.122] ([66.11.173.122:32904] helo=interjinn.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6C/FA-64369-B03D90A4 for ; Tue, 12 May 2009 15:50:35 -0400 Received: from [192.168.1.3] (blobbie [192.168.1.3]) by interjinn.com (Postfix) with ESMTP id 2873438CAD8; Tue, 12 May 2009 15:50:13 -0400 (EDT) To: =?ISO-8859-1?Q?=D3lafur?= Waage Cc: internals@lists.php.net In-Reply-To: <8c35d7690905121235s6d732eedk87ff45855607fdcf@mail.gmail.com> References: <8c35d7690905120935t18722295i69217245c9296a6d@mail.gmail.com> <1242149981.10178.25.camel@localhost> <8c35d7690905121235s6d732eedk87ff45855607fdcf@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Organization: InterJinn Date: Tue, 12 May 2009 15:51:38 -0400 Message-ID: <1242157898.10178.38.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] The constant use of isset() From: robert@interjinn.com (Robert Cummings) On Tue, 2009-05-12 at 19:35 +0000, Ólafur Waage wrote: > On Tue, May 12, 2009 at 5:39 PM, Robert Cummings wrote: > > > On Tue, 2009-05-12 at 18:23 +0100, Lewis Wright wrote: > > > Regarding ifsetor, what's wrong with just using this: > > > > > > isset($myvar) OR $myvar = 'i am set'; > > > > > > It works in just the same way and has no problems. I agree it would be > > > great though if there could be a function to retrieve a variable's > > > value if it exists, without throwing an error if it doesn't exist. I'm > > > not sure if isset would be appropriate though. > > > > > > Lewis. > > > > mixed value_of( $variable [, $defaultValue=null] ); > > > > > > > if( value_of( $_GET['action'] ) == 'edit' ) > > { > > // ... > > } > > > > switch( value_of( $_GET['action'], 'details' ) ) > > { > > case 'details': ... > > } > > > > ?> > > > > Cheers, > > Rob. > > -- > > http://www.interjinn.com > > Application and Templating Framework for PHP > > > > > > Will this run without notices if the value you are passing to the function > isnt set? No, I was suggesting a format for the desired functionality (I should have been more clear). IMHO the above would be the perfect solution if it worked in the same manner as isset() (i.e. doesn't generate notices). Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP