Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46148 Return-Path: <0xcafefeed@gmail.com> Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33336 invoked from network); 21 Nov 2009 20:19:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Nov 2009 20:19:21 -0000 Authentication-Results: pb1.pair.com header.from=0xcafefeed@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=0xcafefeed@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.213 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: 0xcafefeed@gmail.com X-Host-Fingerprint: 209.85.218.213 mail-bw0-f213.google.com Received: from [209.85.218.213] ([209.85.218.213:45656] helo=mail-bw0-f213.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/39-13841-74B480B4 for ; Sat, 21 Nov 2009 15:19:20 -0500 Received: by bwz5 with SMTP id 5so4352749bwz.23 for ; Sat, 21 Nov 2009 12:19:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=y1Fe7aOKc21qwZhGaOFWuZ4L1w3yjBe4+Q+dZjisuIA=; b=KiE1MI4c6FDoSFRYke/eyeeb7uuwPgUXl7h55kalx/WQPAtl+Pc7n28/O1h7EqC1u7 DGsiJs0+HdaqZYc73VS/6EzEuAnNkjxltPLwb2qEDiPk0TEeK255OcriYKCGn1DPG9IV T3SX9i44PpMLISTrjsOniHuaOwHWCLTWe7xN0= 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:content-transfer-encoding; b=nDgKHtXaIBrRm2egtA9foaJrgDRoEkvegvvoSr6HE4cbycPZgu4bRJkoHLlAt9q/aP mSlFRy+KMF5B6kteI4wqmzWz5HyOuLJinhhOI/DZ+GqjlAVgPkyExzqWddELcli+alF+ UM1nIhpj8qCbZunUK9eS115soROX7iBr7SIl0= MIME-Version: 1.0 Received: by 10.204.141.4 with SMTP id k4mr2947050bku.28.1258834757255; Sat, 21 Nov 2009 12:19:17 -0800 (PST) In-Reply-To: <4B082F9E.6080703@lerdorf.com> References: <17.CC.25743.CB6770B4@pb1.pair.com> <84B23126-8011-48DA-B65A-750AA9C5B57E@pooteeweet.org> <4B082F9E.6080703@lerdorf.com> Date: Sat, 21 Nov 2009 12:19:17 -0800 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] suggestion about ternary operator From: 0xcafefeed@gmail.com (mm w) More interesting behaviors to dig are there: variable =3D ?? ; variable =3D ? : ?? ; or a la javascript variable =3D || ; Best, On Sat, Nov 21, 2009 at 10:21 AM, Rasmus Lerdorf wrote= : > Alban wrote: >> Le Sat, 21 Nov 2009 09:48:10 +0100, Lukas Kahwe Smith a =C3=A9crit : >> >>> On 21.11.2009, at 06:12, Alban wrote: >>> >>>> This is not a big problem but if a solution exists, this would be so >>>> cool ! Especialy when we have to check existance of twenty or more key >>>> in array. Code would be be lighter and clear. Since i use PHP, I alway= s >>>> have in my 'common function file' a function like that : >>>> >>>> function getIssetVar($var, $default) { return ((isset($var)) ? $var : >>>> $default); } >>>> >>>> So is it possible to make a little improvement on this operator or >>>> introduce a new operator or a core function which do that ? What's you= r >>>> feeling about it ? >>> >>> this feature request has already been discussed and declined: >>> http://wiki.php.net/rfc/ifsetor >>> >>> please review this rfc before continuing this thread. >>> >>> regards, >>> Lukas Kahwe Smith >>> mls@pooteeweet.org >> >> Thanks for the link to the RFC :) >> >> Excuse me, but I'll be little hard in this post. This for insult the >> community but I want the community really think about the decision it >> made and the reason why. >> >> I also read why it have been refused here : >> http://www.php.net/~derick/meeting-notes.html#ifsetor-as-replacement-for= - >> foo-isset-foo-foo-something-else >> >> Is it serious ? >> >> =C2=AB >> The name for this new operator is heavily disputed and we could not agre= e >> on a decent name for it. >> =C2=BB >> >> Tomorrow I will not send food to the association for children who are >> hungry because I can not choose between offering Thai or basmati rice. >> >> Stop sarcasm, seriously, this is not an honorable response from people >> making decisions. Take your responsibility and make a vote or impose a >> name, just do it. >> >> =C2=AB >> =C2=A0 Instead of implementing ifsetor() we remove the >> =C2=A0 requirement for the "middle" parameter to the ?: operator. >> =C2=BB >> >> That's not people wants and that's not do their need. >> So that not a correct answer of the php developper demand. >> >> =C2=AB >> =C2=A0 In combination with the new input_filter extension >> =C2=A0 you then reach the original goal of setting a default >> =C2=A0 value to a non-set input variable with: >> >> =C2=A0 $blahblah =3D input_filter_get(GET, 'foo', FL_INT) ?: 42; >> =C2=BB >> >> I don't see how do that with the actual filter extension. Even if it is >> possible, this is not a pretty short and easier solution than : >> >> $var =3D (isset($var)) ? $var : 'default'; > > The ternary isn't meant to solve the isset thing you are talking about. > =C2=A0It is simply a shortcut to normal ternary operations. =C2=A0The mos= t common > case where you don't know if a variable is set is on the initial input > via $_GET or $_POST and we definitely don't want people doing: > > =C2=A0$var =3D $_GET['foo'] ?: 42; > > It would be an XSS disaster. =C2=A0Hence the suggestion to use input_filt= er > there, or a similar user-supplied filtering function in which case the > ternary, as it is currently implemented, is perfectly suitable. > > -Rasmus > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >