On 26.04.22 16:36, Rowan Tommins wrote:
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".
Interesting, I didn't know the default value of a checkbox is "on" if no
value is specified. That might make it another sensible value to accept
for implicit bool conversion, even though I am not sure how many
checkboxes are used without setting an explicit value, but it could be
considered an established value, especially with how commonplace HTML
forms and checkboxes are in PHP applications.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to