Sunday, 7 February 2010

take care of php loose comparisons

php has both strict comparison and loose comparison.
see the example.
if("6x"==6)
{
echo "surprice";
}
else
{
echo "i am aware.";
}
in a comparison, if either side has number then both the parameters will be converted to number and will check 6==6, so the output will be "surprice".

In these case, checking with === will work as usual.
eg: if("6x"===6)

4 comments:

  1. http://board.flashkit.com/board/showthread.php?t=628886

    ReplyDelete
  2. http://sixrevisions.com/resources/14-jquery-plugins-for-working-with-images/

    ReplyDelete
  3. http://tutorials.zen-cart.com/index.php?article=111

    ReplyDelete
  4. http://wordpress.org/download/release-archive/

    ReplyDelete

Please share your thought about this