For comparisons between strings, what's faster, the strcmp() function or the manual way (if ($x === $y) .. ) ..?
I've heard mostly that strcmp() is faster, just wanted confirmation from the experts here.. ;) ..
coopster
5:23 pm on May 3, 2004 (gmt 0)
Not in my tests. strcmp is consistently slower, but not by much, about a tenth of a second -- except when the comparison values are numeric, then strcmp is consistently 3 times slower (probably because it has to convert the values to string representation first).
DrDoc
5:49 pm on May 3, 2004 (gmt 0)
=== is usually faster The reason for this being the fact that there are two checks: 1) Are the varibles of the same type? If so, fail immediately 2) Do the variables have the exact same values?
strcmp() first converts the variables to strings, then compares them.