0
why is this php code returning 2 even though its incremented?
<?php $a=2; $b=$a++; echo $b; ?> why does it return 2.. i'm confused..
2 Respuestas
0
That increment placement is postfix, you'll want to use prefix instead. Meaning, $b is assigned to value $a and then incremented after. Writing $b = ++$a will increment before assigning the value and you'll get the result you're looking for.
0
thanks mate.. i get it now? good explanation there