Re: 23 nothing is so as it seems, but why
| From: | Etienne Kneuss | Date: | Thu, 19 Jan 2006 16:56:06 +0000 |
| Subject: | Re: 23 nothing is so as it seems, but why | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-21580@lists.php.net to get a copy of this message | ||
Notice that this behavior can be reproduced using only prefix increment
operators.
<?php
$a = 10;
$b = &$a;
echo (++$a) + (++$a); // 24
?>
<?php
$a = 10;
//$b = &$a;
echo (++$a) + (++$a); // 23
?>
Is that also expected to give undefined results ?
Best regards
Hartmut Holzgraefe a écrit :
> Marco Kaiser wrote:
>> Today during a session i had a strange "magic" feature found in php.
>>
>> <?php
>> $a = 10;
>> echo ++$a + $a++;
>> ?>
>
> there is a very simple rule that PHP inherited from C:
>
> never use pre- and postfix increment operators in the same expression
>
> as the results are undefined
>
--
Etienne Kneuss
http://www.colder.ch/
colder@php.net