php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42230 echo ++$var output differs from $var++
Submitted: 2007-08-07 07:40 UTC Modified: 2007-08-07 07:43 UTC
From: simon@php.net Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.4RC1 OS: debian linux
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: simon@php.net
New email:
PHP Version: OS:

 

 [2007-08-07 07:40 UTC] simon@php.net
Description:
------------
different result from echoing post or pre incrementation of a variable
$count=1;
echo $count++;//echo's 1
echo "\n";
$count=1;
echo ++$count;//echo's 2

its hard to see where this would really be an issue 
 & yes the value of $count is still the same in both scenarios, just seems inconsistent behaviour and could confuddle some basic debugging ?



Reproduce code:
---------------
$count=1;
echo $count++;
echo "\n";
$count=1;
echo ++$count;

Expected result:
----------------
2
2

Actual result:
--------------
1
2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-07 07:43 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 19:01:36 2025 UTC