Monday, April 25, 2011

php <> operator

can anyone tell me what this operator means exactly? is it the same as != (not equal)??

$foo = 'text';

if($foo <> 'photo') {
    echo 'foo';
} else {
    echo 'bar';
}
From stackoverflow
  • Yes, it's the same as != (see manual)

  • That would be correct. It's pretty universal between languages. I usually use that method in my MSSQL queries/stored procedures.

    PHP: Comparison Operators

  • < <= > >= <> have a slightly higher precedence then == != === !== in the order of operations. Aside from the difference in precedence <> and != have the same meaning.

    P.S. You probably should never write code that depends on such a minute difference in the order of operations.

    ocergynohtna : agreed. and thanks to you all. :)
    invenetix : Your welcome. :D

0 comments:

Post a Comment