|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65839 $a = 10; $a = $a++; echo $a; //10 But other language like C, will be output: 11
Submitted: 2013-10-05 16:12 UTC Modified: 2013-10-05 16:17 UTC
From: mehedi6060 at gmail dot com Assigned:
Status: Not a bug Package: *Compile Issues
PHP Version: 5.4.20 OS: Windows 7
Private report: No CVE-ID: None
 [2013-10-05 16:12 UTC] mehedi6060 at gmail dot com
$a = 10;
$a = $a++;
echo $a;
what will be output you thinking? output : 11 ?
Sorry, Output is : 10
Because this is a bug on PHP!
But other language(c,c++) this will be : 11
Mehedi Hasan

Test script:
$a = 10;
$a = $a++;
echo $a; //10
//But the correct output will be : 11

Expected result:
$a = 10;
$a = $a++;
echo $a; //10
//But the correct output will be : 11


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-05 16:17 UTC]
-Status: Open +Status: Not a bug
 [2013-10-05 16:17 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Please see, which explicitly states that evaluation order is unspecified.

The behavior is also undefined in C++, please see ยง1.9/15 of the C++11 standard.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Apr 04 09:01:23 2020 UTC