Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87938 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38040 invoked from network); 26 Aug 2015 18:35:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Aug 2015 18:35:40 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.177 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:38051] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/47-17883-BF60ED55 for ; Wed, 26 Aug 2015 14:35:40 -0400 Received: by wicja10 with SMTP id ja10so23412581wic.1 for ; Wed, 26 Aug 2015 11:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=1sasB+7BeoO8LA1VFDdChiMZyqpT9cmYWaegL0DwwPc=; b=c27XccLkksxNGNN1hglXpH90RwdJeszv5tGPjucqcJ5Ct3BGEkueGhjQYECxYoeNqo 3hTGP1BZgJwTFN4VfUQa2kf/gnRA/k40QJ2WHGmbMOgz+zTkX94jakJprllzX8HUtm0U /dhmfN8ZqYknQvimsU961sJNeMqTlu6cuUiozFUvCcXgwxJM2s/rFf/gcC+VTtrr0BZ9 qn/WAtZUav14b7yxWDz8DdUC5KDBGDu0XUF+KfPFbPlVxUzu54XjUT+K+SHGRLha3OFW HzFq6WZJgpQ6xeF0yGnBMeb/P2KzE8xb1UR1Km+39qGcTTutdeTtXysia+KSYoPwgUMu dGeg== MIME-Version: 1.0 X-Received: by 10.180.20.164 with SMTP id o4mr5967654wie.63.1440614134490; Wed, 26 Aug 2015 11:35:34 -0700 (PDT) Received: by 10.28.183.130 with HTTP; Wed, 26 Aug 2015 11:35:34 -0700 (PDT) In-Reply-To: References: <55DD4269.4090402@gmail.com> <6348DFA7-04BD-41BB-A500-17A8A531B56C@craigfrancis.co.uk> <55DDDEE1.3000001@gmail.com> Date: Wed, 26 Aug 2015 12:35:34 -0600 Message-ID: To: Craig Francis Cc: Stanislav Malyshev , Scott Arciszewski , PHP Internals Content-Type: multipart/alternative; boundary=bcaec53f2e41beac61051e3b1d8b Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: derokorian@gmail.com (Ryan Pallas) --bcaec53f2e41beac61051e3b1d8b Content-Type: text/plain; charset=UTF-8 On Wed, Aug 26, 2015 at 11:08 AM, Craig Francis wrote: > On 26 Aug 2015, at 16:44, Stanislav Malyshev wrote: > > >> Depending on the website I may then add a key to define the > >> 'report-uri', or I may set it to NULL to say that I don't want one. > > > > NULL is not the best value to for this, but the function you're looking > > for is array_key_exists(). > > > > What would be the best value? > > And the array_key_exists() function has already been mentioned (and is > what I'm using... but I cut that bit out to keep the reply shorter, as > mentioned in my previous email). > > What I would do is use false to me I don't want this, and null/not set to mean do the default, and a value to mean this is what I want. Then you end up with: if (!isset($val)) { // do the default } elseif (!empty($val)) { // do something with $val } // else do nothing because I don't want this thing On the other hand, if I'm designing something using null as a special case value, then I would just use array_key_exists and is_null (these calls exist a few times in my code) but generally speaking I try not to give null special meaning. --bcaec53f2e41beac61051e3b1d8b--