Variables are “containers” for storing information.
Creating (Declaring) Variables
[sam id=”4″ codes=”true”]
In PHP, a variable starts with the $ sign, followed by the name of the variable:
After the execution of the statements above, the variable $txt will hold the value Hello world!, the variable $x will hold the value 5, and the variable $y will hold the value 6.5.
Note:- when you assign text value to variable,puts quotes around the value
A variables can have sort name (like x and y) or one more descriptive names (age,total,value).
Rules for PHP variables:
- A Variable start with $ sign followed by the name of the variable
- A Variable start with letter or underscore character
- A Variable can not start with a number
- A Variable can not contain alpha-numeric character and underscores (A-z ,0-9,and _ )
- Variable names are case sensative ($age and AGE are two different variable)
Remember that php variables names are case sensative !!!