PHP - Write program to define variable

Requirements

Write program to define variable

  • Write a script that creates a variable and assigns an integer value to it,
  • then adds 1 to the variable's value three times, using a different operator each time.
  • Display the final result to the user.

Demo

<?php
         $x = 5;//from  ww  w.j  av  a2s. co  m
         $x = $x + 1;
         $x += 1;
         $x++;
         echo $x;
?>

Result

Related Exercise