> Le 27 févr. 2019 à 09:06, Kingsquare.nl - Robin Speekenbrink 
> <ro...@kingsquare.nl> a écrit :
> 
> As of the 0 == "" bit: I do think that an empty string is widespread
> regarded as falsey-string... Thus 0 == "" sould IMHO return true...
> 

0 == "" evaluating to true has been a footgun for me in the past; something 
like that:

```php
$state = $_GET['state'] ?? null;
// ...
switch ($state) {
    case 0: // when $state === "", this branch is incorrectly chosen
    // ...
}
```

where the `state` parameter comes from <select name="state"> and is supposed to 
provide an optional filter criterion for some list.

The fact that both values are falsy doesn’t mean that they should be equal 
(hopefully, `array() == 0` evaluates to false).

—Claude

Reply via email to