Jiew Meng Jiew Meng - 1 year ago 108
PHP Question

String comparison using == vs. strcmp

It seems that PHP's

operator is case sensitive? So is there any reason to use
? Is it safe to do something like:

if ( $password == $password2 ) { ... }

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download