I have following example where PHP IF is giving wrong results, I don't understand why?
Results are correct in these example
$i=0; // i is set to int 0
if( $i == 0){echo 'yes';}else{echo 'no';}echo '<br>';
result yes
$i='string'; // i is set as a string
if( $i == 'string'){echo 'yes';}else{echo 'no';}echo '<br>';
result yes
But results are wrong in these examples
$i='string'; // i is set as a string
if( $i == 0){echo 'yes';}else{echo 'no';}echo '<br>';
result yes
$i=0; // i is set to int 0
if( $i == 'string'){echo 'yes';}else{echo 'no';}echo '<br>';
result yes
Please suggest why this error in comparing, why PHP IF is not comparing correctly.
Thanks