Computer >> Computer tutorials >  >> Programming >> PHP

What happens if ++ operator is used with string value in PHP?


If you try to use ++ operator with string value then it increments the last character value with 1 and prints the ASCII value.

Following is the PHP code −

Example

<!DOCTYPE html>
<html>
<body>
<?php
   $values = 'John';
   echo "The string modified value is=",++$values,"<br>";
      $values1="10.5";
   echo "The string incremented value is=",++$values1;
?>
</body>
</html>

Output

The string modified value is=Joho
The string incremented value is=11.5