Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88323 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50884 invoked from network); 18 Sep 2015 14:07:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2015 14:07:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.180 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.180 mail-wi0-f180.google.com Received: from [209.85.212.180] ([209.85.212.180:34435] helo=mail-wi0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/1A-19961-4BA1CF55 for ; Fri, 18 Sep 2015 10:07:49 -0400 Received: by wicfx3 with SMTP id fx3so65933243wic.1 for ; Fri, 18 Sep 2015 07:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=PxFpntttgTcNew8d9vR0/5gSO4CW4SCaVp+hpQhPiZk=; b=JYSJCKqbXM/RaUV4voPyoLG6UKs4eqtSzHb6+3cgs4ovfOR+QTeo/xSRo8jReKqbSM 4gGJML5kX/4CBaXlr4OlHnl+q9WXsXpDyTdtxJZn0CP+EQXB0dA6YOQEtN4l1auOhsAQ XlVVo4N8jBXUpwyO5W5OKYyvMWUxJdYCL+E4Rh6njXxMoYSMjcRU8to8RkgNukmOss8T YQydImst+I1+xp9rmKa0hEIWloMGTDpBObF8FXl4SCDz/Qjg/oplNCtBDh5Z5uwfl6gd myI1qtkz7R2vJTdwd+QwdrijWQCNHWZrh3HxQpjhcAMtgGOvWUwWpV5ogcNj1dBNg6oW 8mEQ== X-Received: by 10.180.107.102 with SMTP id hb6mr36668822wib.37.1442585265425; Fri, 18 Sep 2015 07:07:45 -0700 (PDT) Received: from [192.168.0.127] ([62.189.198.114]) by smtp.googlemail.com with ESMTPSA id jc9sm15732370wic.6.2015.09.18.07.07.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Sep 2015 07:07:44 -0700 (PDT) To: internals@lists.php.net References: <55F6B911.9080400@gmail.com> <96BE7F01-D04B-483B-B1A3-B45CED6DFCDC@craigfrancis.co.uk> <55F6F08C.1020506@gmail.com> <0BEF6D82-CB5F-49F6-A3A4-3267924A0CDA@thesba.com> <55F72CA9.2060301@gmail.com> <09369945-76FE-4E08-9C2C-15FB0577AD27@thesba.com> <55F752E7.9070801@gmail.com> <55F9B4C7.3050700@gmail.com> <440C64A2-4B4F-4AEF-ACE3-F3A6637EBAB6@thesba.com> <55F9D704.5050002@lsces.co.uk> <55F9EFA2.9020908@lsces.co.uk> <0022A1D9-DC37-4F49-B58E-FBED5AF872BA@gmail.com> <55F9FAB3.2050100@lsces.co.uk> <55FB19CB.7080707@gmail.com> <55FB3117.5040204@lsces.co.uk> <55FB3A60.1040601@gmail.com> <55FB4270.7000204@lsces.co.uk> <55FB4969.7080600@gmail.com> <55FB5BA6.6050606@lsces.co.uk> <55FBF265.5000502@gmail.com> <55FBF7B7.4050603@lsces.co.uk> Message-ID: <55FC1A77.7090406@gmail.com> Date: Fri, 18 Sep 2015 15:06:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55FBF7B7.4050603@lsces.co.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: rowan.collins@gmail.com (Rowan Collins) Lester Caine wrote on 18/09/2015 12:38: > For SQL data coming from any decent database each variable can either > have a value in, ( which may be an empty string ) or be NULL. The NUMBER > of fields returned does not matter, a query returning a single record > can have a variable Again, I know what NULLs are, and how they can come about; but you made it sound like you could run an SQL query and have the first row having 6 columns, and the second having 5, which is not something I've ever seen. (Substitute "record" or "tuple" for "row", and "fields" for "columns", if you prefer.) The number of fields returned DOES matter, because if the same number of fields are returned in every case, then the same variables will be defined in every case, and there would be no case where exists() would return false. But I guess I'll take your word for it that there's some way that the number of fields can vary. > so the third condition is that rather than a field > being NULL, it does not exist, so testing for isset() only works for a > field that 'is set' and empty() only works with an empty value. Sure, sure, I understand that, really, I do. > Checking for the field being present but NULL needs is_null() but THAT throws a > notice for those fields which have not been returned in this particular > result set. Your problem is not "is_null() throws notices", because that would lead to "can I have a version of is_null() which doesn't throw notices?" to which the answer is "yes, use isset()". The null condition is the one which you CAN detect with current functions; it's the "not set" condition which you can't detect, because neither is_null() nor isset() will actually affirm the "present but" bit of your condition. That's not is_null()'s fault, it's behaving the same way as the rest of the language in assuming every uninitialised variable has a null value. > We are not talking about the number of states stored IN a variable OK, maybe your example just wasn't a very good choice then, because "Vehicle is not old enough to need MOT" feels very much like a state being stored somewhere to me. That it is *represented by* a non-existent variable is incidental, all you need is *some way of representing it*. > The date > value can be a valid date ( and genealogical date goes back before most > 'empty' date values ) or NULL indicating no date set OR the variable can > be missing from the result set. If you add in 'empty' one might say we > have four distinct states? A PHP variable can have all sorts of states, because you can take advantage of loose typing: $date = new DateTime(); $date = null; $date = 'TODAY'; $date = -1; $date = M_PI; etc Those are all readily distinguishable, and don't require any changes to the language for you to base your code around them. Regards, -- Rowan Collins [IMSoP]