rfc:strict_operators

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:strict_operators [2020/07/06 15:14]
jasny
rfc:strict_operators [2020/07/15 14:27] (current)
jasny
Line 4: Line 4:
   * Date: 2020-07-06 (first version: 2019-05-25)   * Date: 2020-07-06 (first version: 2019-05-25)
   * Author: Arnold Daniels, <jasny@php.net>   * Author: Arnold Daniels, <jasny@php.net>
-  * Status: Under Discussion+  * Status: Withdrawn
   * First Published at: http://wiki.php.net/rfc/strict_operators   * First Published at: http://wiki.php.net/rfc/strict_operators
  
Line 61: Line 61:
  
 When used with a ''%%bool%%'', ''%%string%%'', ''%%array%%'', ''%%object%%'', or ''%%resource%%'' operand, a ''%%TypeError%%'' will be thrown. When used with a ''%%bool%%'', ''%%string%%'', ''%%array%%'', ''%%object%%'', or ''%%resource%%'' operand, a ''%%TypeError%%'' will be thrown.
 +
 +Custom compare handlers of objects (like ''DateTime'' and ''gmp'') will be applied regardless of ''strict_operators''. The ''ZEND_COMPARE_OBJECTS_FALLBACK'' macro will throw a ''TypeError'' if two objects are compared with different handlers.
  
 ==== String concatenation ==== ==== String concatenation ====
Line 118: Line 120:
 This can lead to issues when numeric comparison is not expected, for example between two hexidecimal values. The hexidecimal value is instead interpreted as number with scientific notation. This can lead to issues when numeric comparison is not expected, for example between two hexidecimal values. The hexidecimal value is instead interpreted as number with scientific notation.
  
-<code>+<code php>
 $red = '990000'; $red = '990000';
 $purple = '9900e2'; $purple = '9900e2';
Line 151: Line 153:
 $a < $b; // true $a < $b; // true
 </code> </code>
- 
-The logic of relational operators other than ''%%==%%'', ''%%===%%'', ''%%!=%%'' and ''%%!==%%'' has limited practical use. 
  
 ==== Strict vs non-strict comparison of arrays ==== ==== Strict vs non-strict comparison of arrays ====
rfc/strict_operators.1594048487.txt.gz · Last modified: 2020/07/06 15:14 by jasny