The Variables are "containers" for storing any information .
Creating And (Declaring) PHP Variables
In PHP, a variable is declared using a dollar $ sign followed by the variable name. Here, some important points to know about variables
<?php $txt = "Hello Stack !"; $x = 5; $y = 3.5; ?>
After the execution of the declare variable above, the variable $txt will hold the value Hello Stack !, the variable $x will hold the value 5, and the variable $y will hold the value 3.5.
Rules of PHP variables:
- The php variable starts with the $ sign, followed by the name of the variable
- A variable name must start with a letter or the underscore character
- A variable name cannot start with a number
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- A Variable names are case-sensitive ($age and $AGE are two different variables)
php automatically judge what type of store value in a variable like string or number or floating point number