String compare trap in php
If string compare with an integer, php will evaluate string to integer intval() and compare it with that integer.
if('test' != 0) {
echo "true";
} else {
echo "false"; // return false
}
if('0test' != 0) {
echo "true";
} else {
echo "false"; // return false
}
if('1test' != 0) {
echo "true"; // return true
} else {
echo "false";
}
echo "true";
} else {
echo "false"; // return false
}
if('0test' != 0) {
echo "true";
} else {
echo "false"; // return false
}
if('1test' != 0) {
echo "true"; // return true
} else {
echo "false";
}
No comments :
Post a Comment