PHP 4.0 Bug #5198: inequality test (!=) failure
| From: | fharvell at fts dot net | Date: | Fri, 23 Jun 2000 03:43:15 +0000 |
| Subject: | PHP 4.0 Bug #5198: inequality test (!=) failure | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-22083@lists.php.net to get a copy of this message | ||
From: fharvell@fts.net
Operating system: RedHat Linux 6.2
PHP version: 4.0.0 Release
PHP Bug Type: Misbehaving function
Bug description: inequality test (!=) failure
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 -----