PHP Variables


Variables are used for storing values, such as numbers, strings or function results. All variables in PHP start with a $ sign symbol. The script shows the variable type can be changed while program executes.
  <html><body>
  <?php
    $x = 10;  echo "$x<br />";
    $x = "Hello!";  echo $x;
  ?>
  </body></html>
   
To concatenate two or more variables together, use the dot (.) operator. The script shows variables do not need to be strings. They could be integer or real numbers or others.
  <html><body>
  <?php
    $txt = "Hello, World!";
    $num = 1000 + $x;
    echo $txt . " " . $num ;
  ?>
  </body></html>
x =    
The assignment operator (‘=’) is used to assign an expression to a variable. There are two string operators: Variable Naming Rules