hi there,
look at this code .... simple string comparision code ......
<?php
$str1="ab";
$str2="aB";
if(($i = strcmp($str1,$str2)) == 0)
echo "Returned : $i and the Strings are equal";
else
echo "Returned : $i and the Strings are not equal";
?>
this works fine .... and returns that strings r not equal and also returns value of $i i.e. 1 (in this case)
BUT ... my question is .... if we remove the BRACES, then where the value of $i goes ?? ... i mean ....
<?php
$str1="ab";
$str2="aB";
if($i = strcmp($str1,$str2) == 0)
echo "Returned : $i and the Strings are equal";
else
echo "Returned : $i and the Strings are not equal";
?>
look at the braces around ........ ($i = strcmp($str1,$str2)) ..... i removed the outer braces in the second code ....
now, the answer is same i.e. strings r not equal .... BUT it doesn't print the value of $i .... where is goes .....
i tried using isset($i) to find out that whether $i is setted or not ?? then it prints true
can any one explain this thing ?? is this related to some operator precedence ... please explain .. i m not getting this by that view also
thanks in advance
viv