"; // output is 2.5 2 // To compare strings, use the C-like string comparison function, strcmp() // Other string functions are listed in Sebesta Table 9.3 $str1 = "15"; $str2 = "hello"; if (strcmp($str1, $str2) == 0) echo $str1 . " equals to " . $str2; else echo $str1 . " not equals to " . $str2; echo "
"; // Equality operator and inequality operator are defined // === returns true only if the variables have the same value and are of the same type // If casting occurred to compare, the result is false // !== returns true if the operands differ in value or in type $z = "15"; if ($x === $z) echo "\$x === \$z returns 1 (i.e., true)
"; else echo "\$x === \$z returns 0 (i.e., false)
"; if ($x !== $z) echo "\$x !== \$z returns 1 (i.e., true)
"; else echo "\$x !== \$z returns 0 (i.e., false)
"; ?>