php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5198 inequality test (!=) failure
Submitted: 2000-06-23 05:43 UTC Modified: 2000-07-18 10:08 UTC
From: fharvell at fts dot net Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.0 Release OS: RedHat Linux 6.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fharvell at fts dot net
New email:
PHP Version: OS:

 

 [2000-06-23 05:43 UTC] fharvell at fts dot net
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 -----

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-24 02:07 UTC] stas at cvs dot php dot net
Failed to reproduce this. Please provide more info.
 [2000-07-18 10:07 UTC] stas at cvs dot php dot net
no user feedback
 [2000-07-18 10:08 UTC] stas at cvs dot php dot net
close. 
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 00:00:01 2026 UTC