Jon Dowland wrote:
On Thu, Jan 19, 2006 at 06:41:17PM +0200, Marco Kaiser wrote:
Today during a session i had a strange "magic" feature found in php.
<?php
$a = 10;
echo ++$a + $a++;
?>
this works perfect as expected. it returns 22.
Odd, I expected 21:
echo (11 + 10)
a = a + 1
nope - discounting the 'undefined behavior' of using pre/post increment
operators, 22 would be the correct assumption - remember, broken into
seperate statements, it's effectively:
$a = 10;
$a = $a + 1; // $a == 11
$a + $a; // $a == 22
echo $a;
$a = $a + 1; // $a == 23
Cheers,
--
Carl
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php