Declaring) PHP Variables
In PHP, a variable is declared using a $ sign followed by the variable name.
- We don’t need to declare the data types of variable, that’s why it called loosely typed language.
- Here we use Assignment Operator (=) to assign the value to a variable.
Rules for PHP variables:
- A variable starts with the
$
sign, followed by the name of the variable - It can only contain alpha-numeric character and underscore (A-z, 0-9, _).
- A variable name must start with a letter or the underscore character
- It cannot start with a number or special symbols.
- Variable names are case-sensitive (
$abc
and$ABC
are two different variables)