Post increment and pre increment in php

Uncategorized 0 Comment 4

pre-increment – first increase the value after it print or assign
Post-increment – first print or assign the value after it increase

Example for integer:
$i=10;
echo ‘++$i – ‘.++$i;
echo ‘$i++ – ‘.$i++;
echo ‘$i – ‘.$i;
Output:
++$i – 11
$i++ – 11
$i – 12
Example for String:
$i = ‘chaitanya’;
echo ‘++i – ‘.++$i;
echo ‘i++ – ‘.$i++;
echo ‘i – ‘.$i;
Output:
++$i – chaitanyb
$i++ – chaitanyb
$i – chaitanyc

Leave a comment

You must be logged in to post a comment.

© 2016 4frienz. Powered By Flowers

Back to Top