php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15037 something wrong with the operator '--'
Submitted: 2002-01-14 23:44 UTC Modified: 2002-06-29 03:39 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: killyoubye at 263 dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.2.0-dev OS:
Private report: No CVE-ID: None
 [2002-01-14 23:44 UTC] killyoubye at 263 dot net
I run below on win2000:
<?
$j = 0;
$num = '2.1';
for ($i=$num;$i>1;$i--)
{
echo "i== $i<br>";
	if ($j++ == 10)
		break;
}
?>

but I get the output:
i== 2.1
i== 2.1
i== 2.1
i== 2.1
i== 2.1
i== 2.1
i== 2.1
i== 2.1
i== 2.1
i== 2.1
i== 2.1

I think something may be wrong with the operator '--'.Maybe I am right.
Good lunk.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-15 00:44 UTC] mfischer@php.net
Interesting approach, but why do you quote 2.1 ? It says that $num is the _string_ "2.1" and not the number 2.1. Just nuke the quoes for $num = 2.1; and you're done.
 [2002-01-15 01:20 UTC] yohgaki@php.net
It seems type jaggling problem to me.
AFAIK, PHP should convert type depends on the context.
for() is the exception? Then it should be explicitly documented.

Openned again to make this clear :)
 [2002-01-15 01:28 UTC] yohgaki@php.net
Version update.
 [2002-01-15 05:29 UTC] hholzgra@php.net
not only related to for,
'--' behaves different for (string)2.1
than it does for (float)2.1
 [2002-06-29 03:39 UTC] andi@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 03:01:29 2025 UTC