Re: strcmp()?
| From: | Joshua Kehn | Date: | Mon, 23 May 2011 13:32:41 +0000 |
| Subject: | Re: strcmp()? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-313102@lists.php.net to get a copy of this message | ||
On May 23, 2011, at 9:28 AM, Alex Nikitin wrote:
> There is an interesting note in the comments for strcmp:
> "Well, I am using PHP 4.0 and both strcmp and strcasecmp appear to be giving me very
> arbitrary and incomprehensible results. When I input strings, it appears that "equal"
> strings return "1", as well as some unequal strings, and that if the first argument is
> "smaller" then I *tend* to get negative numbers, but sometimes I get 1, and if larger I
> *tend* to get numbers larger than 1.. "
>
>
> Guessing that earlier versions of php 4 and before would give the results that would have
> values other then 1, 0, -1, i looked through the change log, but nothing immediately jumped out,
> there was a lot of mbstring work done, and they did add the nat comparison functions, and play with
> the pcre engine a bit, which could have caused this as an unintended result for a few versions, i
> think though it was a bug at some point, so, maybe a php dev would chime in if they remember...?
>
>
> -- Alex --
> --
> The trouble with programmers is that you can never tell what a programmer is doing until it’s
> too late. ~Seymour Cray
All this confusion makes me glad that I'm using === for equality checks instead of strcmp.
Regards,
-Josh
____________________________________
Joshua Kehn | Josh.kehn@gmail.com
http://joshuakehn.com