Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126938 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 67A811A00BC for ; Tue, 25 Mar 2025 20:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742933344; bh=O16CH/VCfZ7OIt3lDFF5BPc/9oBKQgrAVmbeypAifq4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=hdshYFVmOWt/x9UjgUPApSLz1U5/BtRhguI/XXzFYv8Seph9o1eEfEJ/fDiNc47uD +p/uyFIsF6RGBL0OSP61V59z4smxilIk08scvh7IoXkIfzHDAYof4K/mKzneNmRy2j MQFLUbWhCwkZU0AeDys+Ij9DJCxGaPCbAoUaxcHz4LeH7ofVflUin7ITrSJAYEjJAU K+Qkx0YUoXaL14mOIA5OTvPvkXiEjCTwB2C+vXYrgvmBAiXBBgeHNkd4qhXxBwj7bN csORweHsWQYD3/EDsmt3wRmmTtdfUz4ozzXEuezXdDf9vhBFhIF2++/cU1eW51IfKK hQJMH5ZGnXmkw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1FE4A18007C for ; Tue, 25 Mar 2025 20:09:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 Mar 2025 20:09:02 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id 67D72114012B for ; Tue, 25 Mar 2025 16:11:31 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Tue, 25 Mar 2025 16:11:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1742933491; x=1743019891; bh=O16CH/VCfZ7OIt3lDFF5BPc/9oBKQgrAVmbeypAifq4=; b= IJmp881NvM5eDbJbgI3Ppa+Hlaseeg75JhoW8zRFWAlt7dx/Z4dowvxFhpxinTEI n00IZT0HURVaiP64QE5ZWOpEXJiRiWx7Kqc3YBlprgtjY/ckIKBOPfPXBRyXJz6l Vzh9NRKwAFQC8T0jAZSNa88+rbt+YM+qGxmVEdOe18ulXu8OmZRn4fNYC5PjA6Kq Yiwv/9VnkLzQ6XBlv6J7SnPzTRsr2Ck/FvKMl9sdeYd/tB3Oos1CHQXHZp285Sfe 2/t6XBzK5IUAfWjtHCwIQzHcvpE6rZMqqOmL6hKtpvt6oQkOR4Ut3FfA3ONcDmzk cBR7DojiokTC0pvf/j4Hmw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1742933491; x=1743019891; bh=O 16CH/VCfZ7OIt3lDFF5BPc/9oBKQgrAVmbeypAifq4=; b=MFKcxcQwFAYSElAaD ahW61otd/eFXSGFwFyQ+zRo6cZoMI7hweWdMHn+KgFoLYUoIc/KfDSJEe67bWUsL F5RdU88oA0cAR8W6lnsAx416olN7K0au5/ABEpRuDuqi97U8BanLxYI828tk8Zke SfDt8jVhHnduHxXLgUyqVtyERqCSoLQWPMJXRAmTJ/PABLgf4guk4rQ+6S7XL1h4 Vk29HLGRjvYceQQd/brSSqdSyz+u/b6ixSp9sdiBk8BEnHnxsV7qEfR0uERlvaRU u3b6bsU/n2mPoCOppqqjYHnrniMmoupfvn4hr8nzxkci0y96codh5eOEsGv972mN Q63Yw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieefheejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhf fvufgfjghfkfggtgfgsehtqhhmtddtreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhm ihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqe enucggtffrrghtthgvrhhnpeehleffteeigfevudetfedugedtudevledugeeugeelheei hfehgfdtkeevvefgleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 25 Mar 2025 16:11:30 -0400 (EDT) Date: Tue, 25 Mar 2025 20:11:28 +0000 To: internals@lists.php.net Subject: Re: [PHP-DEV] Feedback for nullc Idea User-Agent: K-9 Mail for Android In-Reply-To: <010f0195ce2f5cfc-db04f9b8-7491-4451-8153-aa8b64dde290-000000@us-east-2.amazonses.com> References: <010f0195c30f8ccb-c7fa839e-ec18-4613-9851-9d96b943dca2-000000@us-east-2.amazonses.com> <010f0195cbdcf6cc-8ef65563-7a6b-41d5-88e2-feccb9ff1921-000000@us-east-2.amazonses.com> <6C2C4F10-4F98-4BFC-8B90-946E69026A84@rwec.co.uk> <010f0195ce2f5cfc-db04f9b8-7491-4451-8153-aa8b64dde290-000000@us-east-2.amazonses.com> Message-ID: Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 25 March 2025 16:42:45 GMT, Robert Chapin wrote= : >On 3/25/2025 4:45 AM, Rowan Tommins [IMSoP] wrote: >> The implied default in the first is 'off', but in the second it's 'on'= =2E >I thought the implied default was null=2E By "implied", I'm talking about the observed behaviour: if you give it nul= l, does it *act the same as* when you give it 'off', or when you give it 'o= n'? >>> A different example could be if (coalesce($_POST['tick']) > 10) return= ; >> In this case, the implied default is 0=2E > >I thought the implied default was null=2E=C2=A0 In this case it's more than implied, the engine is literally converting th= e value to zero=2E The logical answer to the question "is null greater than ten?" is "null", = as used by SQL=2E e=2Eg=2E=20 - "I don't know how many apples are in the box=2E" (set num_apples=3Dnull) - "Are there more than ten apples in the box?" (query: num_apples>10) - "I don't know=2E" (result: null) The reason you don't get that answer in PHP is that it looks at the contex= t and "type juggles" the null to an integer, and gives you the answer to "i= s zero greater than ten?" instead=2E (In this specific case, you can't observe the difference, because null wou= ld itself be juggled to false by the if statement; but substitute "less tha= n ten", and you get true in PHP, still null in SQL=2E) Using coalesce($foo) in this example means the reader has to remember or g= uess the type juggling rules to know that it's equivalent to (int)($foo ?? = null), and that (int)null will give 0=2E Writing coalesce($foo, 0) or ($foo ?? 0) is a small cost when writing the = code to save cost every time anyone reads it=2E Rowan Tommins [IMSoP]