php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #282 decrement operator(--) not working for vars from URL
Submitted: 1998-04-17 12:45 UTC Modified: 1998-04-17 12:59 UTC
From: miko at cnt dot pl Assigned:
Status: Closed Package: Other
PHP Version: 3.0 Release Candidate 3 OS: Linux RH5.0
Private report: No CVE-ID: None
 [1998-04-17 12:45 UTC] miko at cnt dot pl
My setup:
php3.0RC3
linux RH5.0
mysql-3.21.29 (compiled in mysql support)
no php3.ini file - defaults compiled in)

A "--" operator doesn't work when the variable is set in URL
(didn't tested POST method, only GET). At the same time, however,
the "++" operator works.

Script "decrtest.html"
<?
#$a=0;
echo "$a"; $a++; echo "$a"; $a++; echo "$a";
$a--; echo "$a";$a--;echo "$a";
$a++; echo "$a";$a++; echo "$a";
?>

Results:
http://localhost/decrtest.html
121012 (this is OK, the first $a=="" so it's not visible)

http://localhost/decrtest.html?a=5
5677789 (BUG - no decrementing)

After uncommenting #$a=0:
http://localhost/decrtest.html
0121012


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-04-17 12:59 UTC] zeev
The reason is that $a is set to "5" and not 5 (type string and not integer), and the decrement operator isn't defined for strings (the increment operator is).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC