rfc:binary_string_comparison

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:binary_string_comparison [2014/08/17 10:55] – sorting regular maberfc:binary_string_comparison [2017/09/22 13:28] (current) – external edit 127.0.0.1
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: Under Discussion
   * First Published at: http://wiki.php.net/rfc/binary_string_comparison   * First Published at: http://wiki.php.net/rfc/binary_string_comparison
  
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 ''zendi_smart_strcmp'' will be unused and marked as deprecated.
  
 === string == string === === string == string ===
-(http://3v4l.org/4KA8M)+(http://3v4l.org/2bIUj)
  
     <?php     <?php
     echo ('1' == '1' ? 'true' : 'false') . " ('1' == '1')\n";     echo ('1' == '1' ? 'true' : 'false') . " ('1' == '1')\n";
     echo ('2' == '1' ? 'true' : 'false') . " ('2' == '1')\n";     echo ('2' == '1' ? 'true' : 'false') . " ('2' == '1')\n";
 +    echo ('0' == '0x0' ? 'true' : 'false') . " ('0' == '0x0')\n";
 +    echo ('0' == '00' ? 'true' : 'false') . " ('0' == '00')\n";
     echo ('1e1' == '10' ? 'true' : 'false') . " ('1e1' == '10')\n";     echo ('1e1' == '10' ? 'true' : 'false') . " ('1e1' == '10')\n";
     echo ('1E1' == '10' ? 'true' : 'false') . " ('1E1' == '10')\n";     echo ('1E1' == '10' ? 'true' : 'false') . " ('1E1' == '10')\n";
Line 51: Line 55:
     true ('1' == '1')     true ('1' == '1')
     false ('2' == '1')     false ('2' == '1')
 +    true ('0' == '0x0')
 +    true ('0' == '00')
     true ('1e1' == '10')     true ('1e1' == '10')
     true ('1E1' == '10')     true ('1E1' == '10')
Line 66: Line 72:
     true ('1' == '1')     true ('1' == '1')
     false ('2' == '1')     false ('2' == '1')
 +    false ('0' == '0x0')
 +    false ('0' == '00')
     false ('1e1' == '10')     false ('1e1' == '10')
     false ('1E1' == '10')     false ('1E1' == '10')
Line 251: Line 259:
  
 ===== 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 PHP Functionality =====
-How to note behavior change? +
-... Is it enough to note it in the change-log or should we trigger a E_DEPRECATED/E_STRICT error in PHP5.next in cases two strings will be compared as numbers and tell in the massage what to do. +
- +
-===== Unaffected PHP Functionality =====+
  
 Only non-strict string to string comparison will be affected. Only non-strict string to string comparison will be affected.
- +Means the operators ''=='', ''!='', ''<'', ''>'', ''>='', ''>='' and related sorting functions using the default sorting flag ''SORT_REGULAR''.
-===== 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 282: Line 284:
  
 ===== References ===== ===== References =====
-http://php.net/manual/en/language.operators.comparison.php +  * http://php.net/manual/en/language.operators.comparison.php 
-http://php.net/manual/en/types.comparisons.php +  http://php.net/manual/en/types.comparisons.php 
-http://php.net/manual/en/language.types.string.php#language.types.string.conversion +  http://php.net/manual/en/language.types.string.php#language.types.string.conversion 
-https://bugs.php.net/bug.php?id=54547+  * http://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting 
 +  * https://bugs.php.net/bug.php?id=54547
  
 ===== Rejected Features ===== ===== Rejected Features =====
 None so far.  None so far. 
rfc/binary_string_comparison.1408272936.txt.gz · Last modified: 2017/09/22 13:28 (external edit)