php is loosely written.
Example
"123" == 123 returns true. to avoid these kind of problems always use === (strict comparison operator) operator which checks for data type too.
strict_comparison_operator.php
#!/usr/bin/php
<?php
if ("123" == 123) {
echo "\"123\" and 123 are equal using == operator";
}
if ("123" === 123) {
echo "\"123\" and 123 are equal using === operator";
}
?>
Output
$./strict_comparison_operator.php
"123" and 123 are equal using == operator
No comments:
Post a Comment