Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51834 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14853 invoked from network); 8 Apr 2011 07:02:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Apr 2011 07:02:13 -0000 Authentication-Results: pb1.pair.com header.from=simpleshot@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=simpleshot@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: simpleshot@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-ew0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:33111] helo=mail-ew0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/71-04268-3F2BE9D4 for ; Fri, 08 Apr 2011 03:02:12 -0400 Received: by ewy2 with SMTP id 2so1001721ewy.29 for ; Fri, 08 Apr 2011 00:02:08 -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:date :message-id:subject:from:to:content-type; bh=r3m0gWvkokxkHBQ51LePs+Ktp5ZGi7pHvdqFhnfUG/I=; b=i8d8BrBTHDhLRfGykSvGCcG794uh3VQ10VOpFNDzNSW4aPLiaYSxqed5igp2rePjqe I73aNnJqpSxG4jVcha8OH3DvchOtr8fNrZPEC0MCtX63/ZBWaM1Lrpdy7aNSvLMTNxFS DiFVKcAnRvmh75imkAWNiftvzP1iMAN4pQvps= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=cZJoWrJCP20qiWRH/36B5PPWx+/txS8YIlh0wiUPHsegKC4TgS06CxwD5hcKWaCPyr sNAGGLxDLJHs09GADsc2pIhP1/LGKlAMT/keasksbsCC7QYfYEUSIFNQvABsXGCbGdZc q5uZRf7y6H5zrAyEvqMvjo4xEya9mLhlp6LLs= MIME-Version: 1.0 Received: by 10.213.23.7 with SMTP id p7mr770909ebb.60.1302246127611; Fri, 08 Apr 2011 00:02:07 -0700 (PDT) Received: by 10.213.14.72 with HTTP; Fri, 8 Apr 2011 00:02:07 -0700 (PDT) In-Reply-To: <4D9E96B6.6060401@lerdorf.com> References: <4D950434.3060704@yahoo.com.au> <4D9E0543.1080600@lerdorf.com> <69.82.36433.EC33E9D4@pb1.pair.com> <4D9E34C4.5000406@lerdorf.com> <4D9E429B.20503@sugarcrm.com> <4D9E96B6.6060401@lerdorf.com> Date: Fri, 8 Apr 2011 03:02:07 -0400 Message-ID: To: PHP Development Content-Type: multipart/alternative; boundary=0015174c3f6ed8b14404a062cd32 Subject: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: simpleshot@gmail.com (Adam Richardson) --0015174c3f6ed8b14404a062cd32 Content-Type: text/plain; charset=ISO-8859-1 > > >> We need to be careful about changing the beahviour of existing > operators. > Indeed. The '?' character already is special, so using '??' seems like a safe, practical approach. However, I'd prefer maintaining the form of the standard ternary operator with the colon ($value = $var['bar'] ?? : 'Bar was not set'; // value ="Bar was not) so the '??' operator could be applied in any situation that one would normally use the standard ternary operator. // standard $value = isset($a[$key]) ? $a[$key] : 'Not set'; // new ?? double ternary that performs isset check and omits second expression $value = $a[$key] ?? : 'Not set'; // new ?? double ternary that performs isset check and uses second expression $value = $a[$key] ?? strtoupper($a[$key]) : 'Not set'; Granted, the last example might be infrequent, but I think there's also a value in keeping the form of the double ternary (if used at all) the same as the standard ternary operator for consistency sake. Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com --0015174c3f6ed8b14404a062cd32--