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/16 11:07] – sorting mabe | rfc:binary_string_comparison [2014/08/17 20:04] – date on internals mabe | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Binary String Comparison ====== | ====== PHP RFC: Binary String Comparison ====== | ||
* Version: 0.1 | * Version: 0.1 | ||
- | * Date: 2014-08-01 | + | * Date: 2014-08-01, internals on 2014-08-17 |
* Author: Marc Bennewitz, php@mabe.berlin | * Author: Marc Bennewitz, php@mabe.berlin | ||
* Status: Draft | * Status: Draft | ||
Line 29: | Line 29: | ||
As a side effect it makes string comparison much faster and force developer to really write what they mean (No need to guess) and to force developers to cast/filter input once which also affects performance. | As a side effect it makes string comparison much faster and force developer to really write what they mean (No need to guess) and to force developers to cast/filter input once which also affects performance. | ||
+ | |||
+ | On C-Level the function '' | ||
=== string == string === | === string == string === | ||
Line 136: | Line 138: | ||
=== sorting of strings === | === sorting of strings === | ||
- | (http:// | + | (http:// |
- | <?php | + | <? |
- | $arr = array(' | + | |
+ | $arr = array(' | ||
| | ||
echo "Sort regular: | echo "Sort regular: | ||
Line 145: | Line 148: | ||
var_dump($arr); | var_dump($arr); | ||
| | ||
- | echo "Sort numeric: | + | echo "Sort numeric: |
sort($arr, SORT_NUMERIC); | sort($arr, SORT_NUMERIC); | ||
var_dump($arr); | var_dump($arr); | ||
Line 155: | Line 158: | ||
Current Behavior: | Current Behavior: | ||
- | | + | |
+ | array(6) { | ||
+ | [0] => | ||
+ | string(2) " | ||
+ | [1] => | ||
+ | string(1) " | ||
+ | [2] => | ||
+ | string(2) " | ||
+ | [3] => | ||
+ | int(2) | ||
+ | [4] => | ||
+ | int(3) | ||
+ | [5] => | ||
+ | string(2) " | ||
+ | } | ||
+ | Sort numeric: | ||
+ | array(6) { | ||
+ | [0] => | ||
+ | string(2) " | ||
+ | [1] => | ||
+ | string(1) " | ||
+ | [2] => | ||
+ | int(2) | ||
+ | [3] => | ||
+ | string(2) " | ||
+ | [4] => | ||
+ | string(2) " | ||
+ | [5] => | ||
+ | int(3) | ||
+ | } | ||
+ | Sort binary: | ||
+ | array(6) { | ||
+ | [0] => | ||
+ | string(2) " | ||
+ | [1] => | ||
+ | string(2) " | ||
+ | [2] => | ||
+ | string(2) " | ||
+ | [3] => | ||
+ | string(1) " | ||
+ | [4] => | ||
+ | int(2) | ||
+ | [5] => | ||
+ | int(3) | ||
+ | } | ||
Changed Behavior: | Changed Behavior: | ||
- | | + | |
+ | array(6) { | ||
+ | [0]=> | ||
+ | string(2) " | ||
+ | [1]=> | ||
+ | string(2) " | ||
+ | [2]=> | ||
+ | string(1) " | ||
+ | [3]=> | ||
+ | int(2) | ||
+ | [4]=> | ||
+ | int(3) | ||
+ | [5]=> | ||
+ | string(2) " | ||
+ | } | ||
+ | Sort numeric: | ||
+ | array(6) { | ||
+ | [0]=> | ||
+ | string(2) " | ||
+ | [1]=> | ||
+ | string(1) " | ||
+ | [2]=> | ||
+ | string(2) " | ||
+ | [3]=> | ||
+ | int(2) | ||
+ | [4]=> | ||
+ | string(2) " | ||
+ | [5]=> | ||
+ | int(3) | ||
+ | } | ||
+ | Sort binary: | ||
+ | array(6) { | ||
+ | [0]=> | ||
+ | string(2) " | ||
+ | [1]=> | ||
+ | string(2) " | ||
+ | [2]=> | ||
+ | string(2) " | ||
+ | [3]=> | ||
+ | string(1) " | ||
+ | [4]=> | ||
+ | int(2) | ||
+ | [5]=> | ||
+ | int(3) | ||
+ | } | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | Existing code that relies on the current behavior on non-strict string to string comparison will only produce the originally expected result if the string representation is the same. This can be easily resolved by explicitly casting one of the operands to an integer or float. | + | Existing code that relies on the current behavior on non-strict string to string comparison will only produce the originally expected result if the string representation is the same. This can be easily resolved by explicitly casting one of the operands to an integer or float respectively define the sorting algorithm. |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
As this is a backwards-incompatible change, this RFC targets PHP.next. | As this is a backwards-incompatible change, this RFC targets PHP.next. | ||
- | ===== Open Issues ===== | + | ===== Affected |
- | How to note behavior change? | + | |
- | ... Is it enough to note it in the change-log or should we trigger a E_DEPRECATED/ | + | |
- | + | ||
- | ===== Unaffected | + | |
Only non-strict string to string comparison will be affected. | Only non-strict string to string comparison will be affected. | ||
- | + | Means the operators '' | |
- | ===== Future Scope ===== | + | |
- | This sections details areas where the feature might be improved in future, but that are not currently proposed in this RFC. | + | |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
Line 193: | Line 278: | ||
===== References ===== | ===== References ===== | ||
- | http:// | + | * http:// |
- | http:// | + | |
- | http:// | + | |
- | https:// | + | * http:// |
+ | * https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
None so far. | None so far. |
rfc/binary_string_comparison.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1