Edit report at http://bugs.php.net/bug.php?id=53999&edit=1

 ID:                 53999
 Updated by:         [email protected]
 Reported by:        charlie at charliesomerville dot com
 Summary:            strcmp() doesn't always return -1, 0, or 1
-Status:             Open
+Status:             Wont fix
 Type:               Bug
 Package:            SPL related
 Operating System:   Mac OS X
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

The documentation for strcmp() does not state it returns -1, 0 or 1:



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



The memcmp() man page also states that (which is what strcmp internally
uses), so if you want the same cross platform behaviour you should alter
your script to do as specified above.


Previous Comments:
------------------------------------------------------------------------
[2011-02-12 08:09:56] charlie at charliesomerville dot com

Description:
------------
PHP's strcmp() return value is inconsistent across operating systems.



On Windows and Linux, strcmp("foo","bar") returns 1. However, on Mac OS
X, 

strcmp("foo","bar") returns 4.



Technically, both of these return values are correct, however the 4 is 

inconsistent with the return values on other operating systems.

Test script:
---------------
<?php



echo strcmp("foo","bar");

Expected result:
----------------
1

Actual result:
--------------
4


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53999&edit=1

Reply via email to