php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39609 increment/decrement inconsistency
Submitted: 2006-11-23 16:31 UTC Modified: 2008-01-01 14:34 UTC
From: arpad@php.net Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.2.0 OS:
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: arpad@php.net
New email:
PHP Version: OS:

 

 [2006-11-23 16:31 UTC] arpad@php.net
Description:
------------
Using the increment or decrement operators immediately following respectively a plus or minus with a non-variable expression produces a parse error.

Reproduce code:
---------------
($a+++$b) // works
(1+$a++)  // works
(1-++$a)  // works
($a+++1)  // works
(1+++$a)  // parse error

($a---$b) // works
(1-$a--)  // works
(1+--$a)  // works
($a---1)  // works
(1---$a)  // parse error


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-23 16:50 UTC] tony2001@php.net
Reclassified as feature request.
 [2007-12-31 23:06 UTC] michael at chunkycow dot com dot au
G'day

Just use brackets, eg. 1-(--$a).
I could not imagine why you would want to complicate the parser in order to do such confusing constructs, the non-bracketed version certain does not pass the 1am test.

1am test: read your code at 1 am after a full day of working, if it makes sense then it passes :)
 [2008-01-01 14:34 UTC] derick@php.net
I don't know why you'd want to write unreadable code like this...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC