Declare Variable in PHP
How to define / declare a variable in PHP?
Explanation
Variables are a temporary storage memory which contains some value.
Rules for declaring PHP variables :
- Variables must start with $ sign, followed by a name.
-
It can start with a letter or an underscore character
But it cannot starts with a number
It can contain only alpha-numeric characters and underscores (like A-z, 0-9, and _, no spaces).
Use assignment operator (=) to assign a value to a variable.
PHP variables are case-sensitive(where $name and $Name are different cases here)
Example
<?php
$name = 'My First Variable in PHP';
$Name = 'hscripts';
echo $name."".$Name;
?>