[ create a new paste ] login | about

Link: http://codepad.org/ncVuJtJu    [ raw code | output | fork | 1 comment ]

PHP, pasted on Mar 14:
1
2
3
4
5
6
7
<?php

$l = 0;

echo $l+ ++$l;
echo PHP_EOL;
echo $l;


Output:
1
2
2
1


Create a new paste based on this one


Comments:
posted by vixter.plus on Mar 21
it is just because all statements are executed from right to left...so the value first incremented and now the value of $l = 1; and then 1 + 1 = 2.
reply