rfc:binary_string_comparison
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:binary_string_comparison [2014/08/04 20:16] – github link + references mabe | rfc:binary_string_comparison [2014/08/16 11:07] – sorting mabe | ||
---|---|---|---|
Line 17: | Line 17: | ||
The current behavior leads to bugs that are very hard to find/catch and it makes code hard to know what's going on. | The current behavior leads to bugs that are very hard to find/catch and it makes code hard to know what's going on. | ||
- | Using strict string comparison helps to workaround such behavior bit it ends up in using strict comparison all over which makes non-strict comparison useless. | + | Using strict string comparison helps to workaround such behavior bit it ends up in using strict comparison all over which makes non-strict comparison useless |
+ | |||
+ | Since PHP 5.2.1 '' | ||
===== Proposal ===== | ===== Proposal ===== | ||
Line 45: | Line 47: | ||
echo (" | echo (" | ||
- | Current Behavior: | + | Current Behavior |
true (' | true (' | ||
Line 60: | Line 62: | ||
false (" | false (" | ||
- | Changed Behavior: | + | Changed Behavior |
true (' | true (' | ||
Line 74: | Line 76: | ||
false (" | false (" | ||
false (" | false (" | ||
+ | |||
+ | === string > string | string >= string | string < string | string <= string=== | ||
+ | (http:// | ||
+ | |||
+ | <?php | ||
+ | echo (' | ||
+ | echo (' | ||
+ | echo (' | ||
+ | echo (' | ||
+ | echo (' | ||
+ | echo (' | ||
+ | echo (' | ||
+ | echo (' | ||
+ | echo (' | ||
+ | echo (' | ||
+ | |||
+ | Current Behavior (handle both strings as numbers): | ||
+ | |||
+ | false (' | ||
+ | true (' | ||
+ | true (' | ||
+ | true (' | ||
+ | false (' | ||
+ | false (' | ||
+ | false (' | ||
+ | false (' | ||
+ | true (' | ||
+ | true (' | ||
+ | |||
+ | Changed Behavior (handle both strings as binary): | ||
+ | |||
+ | false (' | ||
+ | true (' | ||
+ | false (' | ||
+ | false (' | ||
+ | true (' | ||
+ | true (' | ||
+ | true (' | ||
+ | false (' | ||
+ | true (' | ||
+ | false (' | ||
+ | |||
+ | === binary marked strings (since PHP 5.2.1) === | ||
+ | (http:// | ||
+ | |||
+ | <?php | ||
+ | var_dump((binary)' | ||
+ | var_dump(b' | ||
+ | |||
+ | Current Behavior (binary marked strings will be handled numerically): | ||
+ | |||
+ | bool(true) | ||
+ | bool(true) | ||
+ | |||
+ | Changed Behavior (all strings will be handled binary without a context): | ||
+ | |||
+ | bool(false) | ||
+ | bool(false) | ||
+ | |||
+ | === sorting of strings === | ||
+ | (http:// | ||
+ | |||
+ | <?php | ||
+ | $arr = array(' | ||
+ | | ||
+ | echo "Sort regular: | ||
+ | sort($arr); | ||
+ | var_dump($arr); | ||
+ | | ||
+ | echo "Sort numeric: | ||
+ | sort($arr, SORT_NUMERIC); | ||
+ | var_dump($arr); | ||
+ | | ||
+ | echo "Sort binary: | ||
+ | sort($arr, SORT_STRING); | ||
+ | var_dump($arr); | ||
+ | |||
+ | Current Behavior: | ||
+ | |||
+ | TODO | ||
+ | |||
+ | Changed Behavior: | ||
+ | |||
+ | TODO | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== |
rfc/binary_string_comparison.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1