Bug #65839 [Opn->Nab]: $a = 10; $a = $a++; echo $a; //10 But other language like C, will be output: 11
Edit report at https://bugs.php.net/bug.php?id=65839&edit=1
ID: 65839
Updated by: nikic@php.net
Reported by: mehedi6060 at gmail dot com
Summary: $a = 10; $a = $a++; echo $a; //10 But other language
like C, will be output: 11
-Status: Open
+Status: Not a bug
Type: Bug
Package: *Compile Issues
Operating System: Windows 7
PHP Version: 5.4.20
Block user comment: N
Private report: N
New Comment:
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 http://www.php.net/support.php 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 http://php.net/manual/en/language.operators.precedence.php,
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.
Previous Comments:
------------------------------------------------------------------------
[2013-10-05 16:12:29] mehedi6060 at gmail dot com
Description:
------------
$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
Thanks.
Mehedi Hasan
mehedi6060@gmail.com
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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65839&edit=1
Thread (2 messages)