|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-06-11 09:46 UTC] sander@php.net
[2002-06-11 09:57 UTC] manderson at dsrglobal dot com
[2002-06-11 10:00 UTC] manderson at dsrglobal dot com
[2003-06-04 02:04 UTC] simon at esoft dot dk
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 18:00:01 2025 UTC |
When comparing two strings for equality they appear to be, if possible, being converted to integers prior to the comparison even when explicitly cast. The following script should demonstrate the issue: <?php if("0123" == "123") { echo "\"0123\" == \"123\"<br />\n"; } if("0123" != "123") { echo "\"0123\" != \"123\"<br />\n"; } if((string) "0123" == (string) "123") { echo "(string) \"0123\" == (string) \"123\"<br />\n"; } if((string) "0123" != (string) "123") { echo "(string) \"0123\" != (string) \"123\"<br />\n"; } if(!strcasecmp("0123", "123")) { echo "strcasecmp(\"0123\", \"123\") returns equal<br />\n"; } else { echo "strcasecmp(\"0123\", \"123\") returns not equal<br />\n"; } ?> This script will echo : <output> "0123" == "123" (string) "0123" == (string) "123" strcasecmp("0123", "123") returns not equal </ouput> Obviously "0123" is not the same as "123". <configuration> './configure' '--with-mysql' '--with-xml' '--with-apxs' '--with-config-file-path=/etc/httpd' </configuration>