Increment and Decrement of a string in PHP
<?php
$string = 'abc';
echo $string; // outputs abc
$string++;
echo $string; // outputs abd
$string++;
echo $string; // outputs abe
++$string;
echo $string; // outputs abf
++$string;
echo $string; // outputs abg
$string--;
echo $string; // outputs abg
$string--;
echo $string; // outputs abg
--$string;
echo $string; // outputs abg
--$string;
echo $string; // outputs abg
/* Decrement operator doesn't have any effect on string but increment operator increases the last character of the string. If we use increment operator when the last character of a string is Z or, z then the the last character will be A or, a respectively. */
?>
$string = 'abc';
echo $string; // outputs abc
$string++;
echo $string; // outputs abd
$string++;
echo $string; // outputs abe
++$string;
echo $string; // outputs abf
++$string;
echo $string; // outputs abg
$string--;
echo $string; // outputs abg
$string--;
echo $string; // outputs abg
--$string;
echo $string; // outputs abg
--$string;
echo $string; // outputs abg
/* Decrement operator doesn't have any effect on string but increment operator increases the last character of the string. If we use increment operator when the last character of a string is Z or, z then the the last character will be A or, a respectively. */
?>
Comments
Post a Comment