Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51964 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54400 invoked from network); 20 Apr 2011 18:58:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Apr 2011 18:58:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=markg85@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=markg85@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: markg85@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:59515] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 41/0C-24878-4CC2FAD4 for ; Wed, 20 Apr 2011 14:58:13 -0400 Received: by qwi4 with SMTP id 4so578242qwi.29 for ; Wed, 20 Apr 2011 11:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=WfziJzhGI93wcL1gJf1AZ+1988WlB3gmTpvMDj48as4=; b=unH1WzTXGADKmV9QKOkUCh3sim+Ouzg1pkpo93ylXu1z/mRN3UGiTMqvG2setOXHF7 K0jI+2qxDCbQAZ1rF+ICSx5Q4qDWfC1aJNG+pIc/CBmLecT3FxmBNO5VnK5D1cRI8ePT Sj/xnFhWrFsuzEwJIy9IWkZzO4g6L2YzMa2Ts= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=vj5mjvuJ+Qc3VT96sGALuQPLXeYk+bRw9kljBjq5QgYzGPW+/88OJ+ALRBspWcMeEF viCYaypoyx29FGhnF+xogz1zE3N49YK5H3dAchr/rD1YOY5rTL/biD36hwV0lCx+Jrye hgFxtjLw/N+2vATBdSca+dyJ2dBh13jX48JZY= Received: by 10.224.196.193 with SMTP id eh1mr670954qab.236.1303325890099; Wed, 20 Apr 2011 11:58:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.185.200 with HTTP; Wed, 20 Apr 2011 11:57:49 -0700 (PDT) In-Reply-To: <002301cbff74$0994b160$1cbe1420$@com> References: <002301cbff74$0994b160$1cbe1420$@com> Date: Wed, 20 Apr 2011 20:57:49 +0200 Message-ID: To: Jonathan Bond-Caron Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf3005ded0b4b98b04a15e347a Subject: Re: [PHP-DEV] Function proposal: varset From: markg85@gmail.com (Mark) --20cf3005ded0b4b98b04a15e347a Content-Type: text/plain; charset=ISO-8859-1 On Wed, Apr 20, 2011 at 6:00 PM, Jonathan Bond-Caron wrote: > On Wed Apr 20 10:55 AM, Mark wrote: > > > > function varset($arr, $key, $default = '') { return (isset($arr[$key]) > > ? $arr[$key] : $default); } > > > > where the call would be: > > $var = varset($_GET, 'var'); > > > > I personally like both ways... > > My proposal is to make this function a core php function in PHP 5.4. > > The added benifit is obvious. People can, with this, use a way shorter > > notation to validate if a given array element exists. Right now that > > needs to be done with a ternary, filter_var or some other method > > (there are quite a few ways to check for existence). > > > > I tried to look in the PHP source to see if i could make a patch to > > add this but i couldn't find the function that defines the isset > > function (i wanted to base it on that). So a pointer to the right > > location would be nice (along with docs that tell me what i all need > > to do to implement a new php function). > > > https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_language_parser.y?rev > ision=306938&view=markup > > Look for "isset_variables:", then zend_do_isset_or_isempty > > isset() lives in the parser and requires some advanced knowledge of the > opcodes (personally I'm not there yet) > Oh boy, i never ever did anything in the core PHP coding so i'm certainly not likely to be able to understand all of that. (yet) > > > > > So, what do you think of this? > > > > I like the idea, it could also be called vardef() or var_default() > > > @ the rest. The list idea is nice, but i don't really see the added value for it.. Lets keep it simple, oke :) As for that other thread: "[PHP-DEV] Implicit isset/isempty check on short-ternary operator" I don't really know much of it, but does that mean that my suggestion is rejected even before i made an RFC for it? Regards, Mark --20cf3005ded0b4b98b04a15e347a--