php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26477 Problems with negative Integers in If-Clauses
Submitted: 2003-11-30 16:56 UTC Modified: 2003-11-30 18:56 UTC
From: languitar at languitarium dot de Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.0.0b2 (beta2) OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: languitar at languitarium dot de
New email:
PHP Version: OS:

 

 [2003-11-30 16:56 UTC] languitar at languitarium dot de
Description:
------------
PHP 5 beta 2 seems to do strange things when using a comaprisson wiht negative values in an If-clause. Sometimes the if-part will work as well as the else-part and sometimes the if-part will be used two times.

Reproduce code:
---------------
$x = -1;
if($x == -1){ echo "if"; } else { echo "else"; }

Expected result:
----------------
if

Actual result:
--------------
ifif

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-30 16:58 UTC] derick@php.net
Works fine for me...:

derick@kossu:~$ php-5.0dev
<?php $x = -1;
if($x == -1){ echo "if"; } else { echo "else"; }
?>
if
 [2003-11-30 17:14 UTC] languitar at languitarium dot de
This Code was used in a class. I didn't notice that the problem seems to be connected with that fact.
 [2003-11-30 17:56 UTC] iliaa@php.net
Please provide a COMPLETE (as short as possible) source code that can be used to replicate the problem.
 [2003-11-30 18:50 UTC] languitar at languitarium dot de
class categories {
	
	function getfolders($folderid = -1, $depth = -1) {
		
		if($folderid == -1) {
			echo "if";
		} else {
			echo "else";
                }
        }
}

$categories = new categories

$categories->getfolders(6);



the output is "ifelse" in my case.
 [2003-11-30 18:56 UTC] iliaa@php.net
Once the parse error in the sample script is fixed it works perfectly.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 04:01:29 2024 UTC