Re: [RFC] Saner string to number comparisons
| From: | Kingsquare.nl - Robin Speekenbrink | Date: | Wed, 27 Feb 2019 08:06:33 +0000 |
| Subject: | Re: [RFC] Saner string to number comparisons | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-104528@lists.php.net to get a copy of this message | ||
Op di 26 feb. 2019 om 13:27 schreef Nikita Popov <nikita.ppv@gmail.com>:
> Hi internals,
>
> I think it is well known that == in PHP is a pretty big footgun. It doesn't
> have to be. I think that type juggling comparisons in a language like PHP
> have some merit, it's just that the particular semantics of == in PHP make
> it so dangerous. The biggest WTF factor is probably that 0 == "foobar"
> returns true.
>
> I'd like to bring forward an RFC for PHP 8 to change the semantics of ==
> and other non-strict comparisons, when used between a number and a string:
>
> https://wiki.php.net/rfc/string_to_number_comparison
>
> ...
>
> Regards,
> Nikita
>
Dear All,
From a user-space POV this is a very good way forward and I (personally)
really like the proposal of having a transitional period (7.4 anyone?)
As of the 0 == "" bit: I do think that an empty string is widespread
regarded as falsey-string... Thus 0 == "" sould IMHO return true...
Just my 2 cents, keep up the excellent Nikita!
(and everyone else ofcourse)
Regards,
Robin