On Wed, 2 Mar 2022 at 14:58, Andreas Leathley <a.leath...@gmx.net> wrote:

> Comparisons with == are quite worthless



Yep, but I'm focusing on how PHP works today, and while I welcome and
encourage improvements to the language, it has to be done gracefully...
forcing strict type checking on everyone (even if it's only for null), is
only going to cause upgrade problems.


I don't think I have used == in the last 5 years, and life has gotten so
> much better because of it.
>


Yep, and I urge (not require) the developers I work with to do this... and
I don't for the kids at code club; they are just getting started, and they
are learning what a if statement is; if I add type checking as well, things
"break", they lose interest, and go off to do something else, like the
PiCar :-)


Why not write:
>
> $name = ($_POST['name'] ?? '');
>


You can, but take the frameworks I noted earlier (and in the RFC). they
don't do this because sometimes it's useful to tell the difference between
a user provided Empty String, vs not set (NULL).

There is a lot of code that uses null coercion, even little things like
`setcookie('name', $name, NULL, NULL, NULL, true)` with 4 NULL's that work
today, but will fatal error in the future.

Craig

Reply via email to