Re: Operations in PHP Hi, Increment/decrement operators
As you can see from the previous table, there’s a difference in the value of
post- and pre-increment. However, in both cases, $var is incremented by 1. The
only difference is in the value to which the increment expression evaluates.
Example 1:
$num1 = 5;
$num2 = $num1++;// post-increment, $num2 is assigned $num1's original
➥value
print $num1; // this will print the value of $num1, which is now 6
print $num2; // this will print the value of $num2, which is the
➥original value of $num1, thus, 5
__________________ Regards,
Senraj.A |