1. What are variables?
Typically php scripts are generate the output dynamically. The php scripts itselfs (the contents of the files) are static however. So we need something which can be dynamic filled. For this there are so called variables. These are filled by the php script and can be reuse later in the script.
2. Syntax of variables
All variables in php starts with the dollar character $. After
that the name of the variable starts with a letter or the underscore _.
And after that the name can also use digits. Variables which begins with
an underscore has some special meaning. For this reason the php developer
shouldn't use own variables which start with an underscore.
<?php
$valid
$10_not_valid
?>
Variables are case-sensitive, so its important how you write your variables.
The variable $foo is not the same as the variable $FOO.
This is important as the superglobal variables like $_GET are not
written as $_get.
3. Assignment operator
To fill a variable with a value you use the assignment operator =.
The variable must be written on the left of the = character, the value to save
must be written on the right.
<?php
$var = 'Content';
$123 = "not valid :(";
$some_variable = $another_variable;
?>
After we filled the variables with values we can use e.g. with echo
<?php
$email = 'foo@example.com';
echo 'Your email is: ';
echo $email;
?>