tags:

views:

111

answers:

2

it seems that PHP's == operator is case sensitive? so is there any reason to use strcmp()? isit safe to do something like

if ( $password == $password2 ) { ... }
+2  A: 

You can use strcmp() if you wish to order/compare strings lexicographically. If you just wish to check for equality then == is just fine.

Daniel Egeberg
Like in [usort](http://us2.php.net/manual/en/function.usort.php). In fact, it's pretty much made for sorting.
Charles
@Charles Thanks. Wikipedia made my eyes glaze over.
banzaimonkey
+3  A: 

The reason to use it is because strcmp

returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.

== only returns true or false, it doesn't tell you which is the "greater" string.

deceze
icic tho in my current case, i dont need to know which string is greater :)
jiewmeng