Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70402 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45733 invoked from network); 26 Nov 2013 14:43:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Nov 2013 14:43:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@chrislondon.co; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@chrislondon.co; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain chrislondon.co does not designate 209.85.212.173 as permitted sender) X-PHP-List-Original-Sender: me@chrislondon.co X-Host-Fingerprint: 209.85.212.173 mail-wi0-f173.google.com Received: from [209.85.212.173] ([209.85.212.173:37589] helo=mail-wi0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E7/51-39355-383B4925 for ; Tue, 26 Nov 2013 09:43:16 -0500 Received: by mail-wi0-f173.google.com with SMTP id hm4so5272267wib.12 for ; Tue, 26 Nov 2013 06:43:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=e4SveIpedOL8wMNvlwechdJvY06ZiBmKgZZZCR9ceNI=; b=mrxntOBapDqIbafhNLHk5fFI+t0liZ7TLrMlx8wKxruklo0WZEHGY62nkq+L+yfsiI uWxcgGFmaUOuUU0oybzxlDiSvHZXhiUwevKBAP9DtUtrNqLiVyr/WnsCTYWjNq5nNVIQ 4sF9gs4Td2DsjQnuPfvRtnHT2M6//xgOX5/dto/iT7viHOqF7bylISEuShm5qF4LyXnL NfgIlxk6znphRoLhKDf1Gk0D5SCTQ9qkR36kYmPZ6ymUuZcfN3aNBsYFsc4le1KsEkVh Bm8iJmGx6uQj/M5WzWiK4FNHwwJEUWUc2w+VOmmySHuiwtQhZt3wwvecVJNucqPEHZBt SvDQ== X-Gm-Message-State: ALoCoQllreS2fel8xxVjBZHk11gngbcCeqzw00e3vSgyzHP05u+tjQBZN1NOzjH+slyYjdB5PtT8 MIME-Version: 1.0 X-Received: by 10.194.175.66 with SMTP id by2mr6220571wjc.59.1385476992284; Tue, 26 Nov 2013 06:43:12 -0800 (PST) Received: by 10.217.153.135 with HTTP; Tue, 26 Nov 2013 06:43:12 -0800 (PST) X-Originating-IP: [66.219.207.210] Date: Tue, 26 Nov 2013 07:43:12 -0700 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e013d19f8f84e5d04ec157f55 Subject: [Proposal] Modification to ?: functionality From: me@chrislondon.co (Chris London) --089e013d19f8f84e5d04ec157f55 Content-Type: text/plain; charset=ISO-8859-1 I find in a lot of my code I have ternaries that set default values. I also find that I can't use the ?: syntax for one reason and one reason only. It throws a notice if the value isn't set. I believe these two statements are functionally equivalent: $foo = $foo ? $foo : 'default'; $foo = $foo ?: 'default'; I would like to change it so it also checks for isset() so I propose the following would be functionally equivalent: $foo = isset($foo) && $foo ? $foo : 'default'; $foo = $foo ?: 'default'; Random addition: what if we also allowed the following shorthand? $foo ?= 'default'; or possibly: $foo ?:= 'default'; Thanks everyone, Chris --089e013d19f8f84e5d04ec157f55--