php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28968 Comparing Values (Rare - But not the first time on similair bugs)
Submitted: 2004-06-30 08:51 UTC Modified: 2004-07-06 15:35 UTC
From: james_mitchell_au at yahoo dot com dot au Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.7 OS: Windows
Private report: No CVE-ID: None
 [2004-06-30 08:51 UTC] james_mitchell_au at yahoo dot com dot au
Description:
------------
This is as wierd and unique as problems get.

Look at the following line in my code:
if(strcmp($grid[$x-1][$y],'-')==0) {

On the machine I Was building it on, I tried:
if($grid[$x-1][$y] == '-') {

millions of times, and each time it would compare the value '0' with '-' and return true, I checked that same line of code hundreds of times, till I finally went to try strcmp and it worked fine

I have had previous problems on another machine a RH Linux one, when comparing 3's at which time I used trim() but that was using an earlier version of 4, probably near a year ago. But had not had similair problems up until now.

I tried this on another machine just now and it worked fine..

I don't have access to the machine the problem was occuring on at this current time, but I will try to with in the next couple of days and get the machine specs to better describe them, hopefully get someone to match them up against and test it.

The test data to use is:
***************
*o*-----*-*---*
*-*****-*-*-*-*
*---------*-*-*
*-****-**-*-*-*
*-*--*-**-*-*-*
*-*--*------*-*
*-*-**-*-**-*-*
*---*--*-**-*o*
***************

Reproduce code:
---------------
http://kicken.mine.nu:8008/extras/bugs/task5.phps

Expected result:
----------------
***************
*o*-----*-*ooo*
*o*****-*-*o*o*
*oooooo---*o*o*
*-****o**-*o*o*
*-*--*o**-*o*o*
*-*--*oooooo*o*
*-*-**-*-**-*o*
*---*--*-**-*o*
***************

With successful run, and nothing on an unsuccessful run


Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-06 15:35 UTC] sniper@php.net
That's the correct behaviour... Please see the operators page in manual and find '===' operator..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Aug 17 06:01:27 2024 UTC