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
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: 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 06:01:28 2024 UTC