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

PHPServer Side ProgrammingProgramming

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

 Live Demo

<!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
raja
Published on 20-Nov-2020 10:00:51
Advertisements