|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-06-24 02:07 UTC] stas at cvs dot php dot net
[2000-07-18 10:07 UTC] stas at cvs dot php dot net
[2000-07-18 10:08 UTC] stas at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 21:00:02 2026 UTC |
The inequality test (!= or <>) fails to indicate an inequality when comparing an array with a string. (Note that this also is incorrect in PHP 3.0.12.) The following script illustrates this: ----- cut ----- $val = array("Test Array"); $str = "Test String"; print("<br>\$val:<pre>"); var_dump($val); print("</pre><br>"); print("<br>\$str:<pre>"); var_dump($str); print("</pre><br>"); if ($val == $str) { print("<br>\"$val\" == \"$str\" is true and incorrect<br>"); } else { print("<br>\"$val\" == \"$str\" is false and correct<br>"); } if ($val != $str) { print("<br>\"$val\" != \"$str\" is true and correct <br>"); } else { print("<br>\"$val\" != \"$str\" is false and incorrect<br>"); } ----- cut ----- When the above is executed, it produces the following incorrect result: ----- cut ----- $val: array(1) { [0]=> string(10) "Test Array" } $str: string(11) "Test String" "Array" == "Test String" is false and correct "Array" != "Test String" is false and incorrect ----- cut -----