Re: Stricter implicit boolean coercions

From: Date: Tue, 26 Apr 2022 14:36:23 +0000
Subject: Re: Stricter implicit boolean coercions
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-117618@lists.php.net to get a copy of this message
On 26/04/2022 14:53, Andreas Leathley wrote:
'on' is only true by "accident" though, because it is a non-empty string, not because of its meaning, and then it is likely that the value 'off' could also be added at some point - which also would be true.
The reason I gave that particular example is that it's the default submission value for an HTML checkbox when checked; if it's not checked, it has no value at all (not even an empty string), so in that particular context there is no corresponding "off". I think it falls into the same category as something like '1e3' being considered numeric - occasionally useful, but probably not worth the potential confusion of a special case. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#117618) next »