Page 1 of 1

Strange If

Posted: Fri Aug 10, 2007 4:24 am
by Behzad
Why the result of the following "if-statement" is true?

Code: Select all

<?php

$x = 0;
if ($x == "salam") echo "Oops!";

Posted: Fri Aug 10, 2007 5:03 am
by stereofrog
When you compare a number with a non-number, php converts the latter and does numeric comparison.
Check Types/Type juggling and Operators/Comparison chapters in the manual.