PROGRAMMING

  minte9
MEMORYApp




S R Q
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Identity

True if only operands are of the same data type and the same value.
 
/**
 * Identical operator
 */

$x1 = 'xn--google.com';
$x2 = 'google.com';

var_dump(stripos($x1, 'xn--') === 0); // true - Correct
var_dump(stripos($x2, 'xn--') == 0);  // true - Incorrect

Confusion

It's easy to confuse the assignment operator = for the comparison operator ==
 
/**
 * Comparition operator, prone to error
 */

$a = 10;
$b = 9;

var_dump($a == 10);     // true
var_dump(10 == $a);     // true, better

if ($b = 10) echo $b;   // 10 - Incorrect

Inequality

While the process is clear for numbers, things change a bit for other data types.
 
/** 
 * Comparing strings
 *
 * D > C, a > A 
 * 
 * ASCII value of a (97)
 * ASCII value of A (65)
 */

var_dump("ABC" > "ABD");        // false
var_dump("apple" > "Apple");    // true

Questions    
Last update: 12 days ago
Logical