php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48112 Printing a "++"
Submitted: 2009-04-29 20:34 UTC Modified: 2009-04-29 20:52 UTC
From: colin at shuaige dot org Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.9 OS: Windows Server 2003 (and others)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 - 18 = ?
Subscribe to this entry?

 
 [2009-04-29 20:34 UTC] colin at shuaige dot org
Description:
------------
Printing a short-hand addition statement ("++") produces the value of the integer before the statement was run instead of the integer "+ 1".

Reproduce code:
---------------
$test = 0;

echo $test++;
// produces "0"

echo $test;
// produces "1"

Expected result:
----------------
$test = 0;

echo $test++;
// produces "1"

echo $test;
// produces "1"

Actual result:
--------------
$test = 0;

echo $test++;
// produces "0"

echo $test;
// produces "1"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-29 20:52 UTC] rasmus@php.net
You have discovered the post-increment operator.

Suggested reading: http://www.php.net/manual/en/language.operators.increment.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 11:01:34 2024 UTC