Description
Pre-increment ( ++$y; ) : Increments $y by one , then returns $y .
Post-increment ( $y++; ) : Returns $y , then increments $y by one .
( Unary operator )
Pre-increment ( ++$y; ) : Increments $y by one , then returns $y .
Post-increment ( $y++; ) : Returns $y , then increments $y by one .
( Unary operator )
<?php
$b ; $a = 0 ; // Declare Variables
$b = ++$a ;
print (" b = {$b} ");
print (" a = {$a} ");
?>
b = 1 a = 1
<?php
$y ; $z = 0 ; // Declare Variables
$y = $z++ ;
print (" y = {$y} ");
print (" z = {$z} ");
?>
y = 0 z = 1
----The PHP version used in this example is 8.4.5 ----