php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15407 The " == " op does not work
Submitted: 2002-02-06 16:00 UTC Modified: 2002-02-06 16:57 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: piapoco at excite dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.1.1 OS: Windows 2000
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: piapoco at excite dot com
New email:
PHP Version: OS:

 

 [2002-02-06 16:00 UTC] piapoco at excite dot com
I'm using Apache and IIS 5.

When I use the comparison operator ( == ), my code fails. But when I use a single ( = ), it goes fine. I'm using the plain config that comes with Apache and PHP, but added a line to have .incs treated in the server.

This is the lame code:

if ($myrow == mysql_fetch_array($Recset))
{
  $gIDClient = $HTTP_POST_VARS["IDClient"];
}

The assigment never gets touched and no error messages are issued. 
Weird, ain't it?
Thanks.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-06 16:08 UTC] jan@php.net
= is no comparison operator but an assignment operator. since a $var = "bla" is not very error prone of course it "works" but that is logically not what you want. additionally the == operator on arrays is not veryhelpful. I suggest, you read the manual sections about "Assignments", "Comparision", "Arrays" and "Array Functions". No bug -> bogus 
 [2002-02-06 16:57 UTC] mfischer@php.net
>'since a $var = "bla" is not very error prone of course it "works"'

"of course" is not right. the assignment will be done and the value of the expression will be used to determine whether the if() will be true or not. If mysql_fetch_array() would return false or null, the "of course" is not true anymore
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 22:01:33 2024 UTC