rfc:strict_operators:faq
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
rfc:strict_operators:faq [2020/07/06 11:50] – jasny | rfc:strict_operators:faq [2020/07/06 13:46] – jasny | ||
---|---|---|---|
Line 57: | Line 57: | ||
Strict comparison of arrays as unsorted hashmaps currently isn't possible and requires sorting the array, prior to comparison. | Strict comparison of arrays as unsorted hashmaps currently isn't possible and requires sorting the array, prior to comparison. | ||
- | With '' | + | With '' |
+ | |||
+ | <code php> | ||
+ | ksort($array1); | ||
+ | ksort($array2); | ||
+ | |||
+ | $array1 === $array2; | ||
+ | </ | ||
Array functions might be added to compare arrays in different ways. But that's outside the scope of this RFC. | Array functions might be added to compare arrays in different ways. But that's outside the scope of this RFC. | ||
+ | |||
+ | ==== How can objects be compared by property? ==== | ||
+ | |||
+ | With the '' | ||
+ | |||
+ | When using strict_operators, | ||
+ | |||
+ | |||
+ | <code php> | ||
+ | get_class($object1) === get_class($object2) && get_object_vars($object1) === get_object_vars($object2); | ||
+ | </ | ||
+ | |||
==== Why isn't is allowed to increment strings with strict_operators? | ==== Why isn't is allowed to increment strings with strict_operators? |
rfc/strict_operators/faq.txt · Last modified: 2020/07/06 15:01 by jasny