The main way to store information in the middle of a PHP program is by using a variable.
The most important things to know about variables in PHP
All variables in PHP are denoted with a leading dollar sign ($).
The value of a variable is the value of its most recent assignment.
Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right.
Variables can, but do not need, to be declared before assignment.
Variables in PHP do not have intrinsic types - a variable does not know in advance whether it will be used to store a number or a string of characters.
Variables used before they are assigned have default values.
PHP does a good job of automatically converting types from one to another when necessary.
PHP variables are Perl-like.
See this example:
Following is the example to store string, integer and float values in PHP variables.
Output:
Output:
In PHP, variable names are case sensitive. So variable name "book" is different from Book, BOOK, BoOk etc.
Output:
PHP variables must start with letter or underscore only.
PHP variable can't be start with numbers and special symbols.
Output:
Invalid PHP Variables
Output: