Hello Robert,

On Tue, 14 Nov 2023 at 11:09, Robert Landers <landers.rob...@gmail.com> wrote:
>
> Andreas,
>
> Just out of curiosity, what is the use case for this? I can't really
> think of a practical case where strict checking is needed for these
> functions. Usually, you have a really good idea of what is in the
> arrays when writing the code and can handle any edge cases (like
> nulls, empty strings, etc) long before you reach for these functions.

I could ask the reverse question: When do you ever need a non-strict comparison?
I think in most modern php development, you would prefer the strict
comparison version simply because it is more simple and predictable.

But for real examples.
One thing I remember is array_diff($arr, [null]) to remove NULL
values, without removing empty strings.
Perhaps we could say this is a special case that could be solved in
other ways, because we only remove one value.

Another thing is when writing reusable general-purpose functions that
should work for all arrays.
The caller might know the types of the array values, but the developer
of the reusable function does not.

Another problem is if your arrays contain anything that is not
stringable. like objects and arrays.

Maybe I will remember other examples that are more practical.

Btw, as a general note on strict vs non-strict:
In some cases you want a "half strict" comparison, where '5' equals 5,
but true does NOT equal '1'.
But for now I am happy to focus on pure strict comparison.

Andreas


>
> Robert Landers
> Software Engineer
> Utrecht NL
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>

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

Reply via email to