PHP variables are used to store characters, numbers, arrays and even object resources, etc., so that we need to use the place.
To define the syntax of a variable:
$variable name = value;
Example of using variables:
<?php $var_char = "Hello!"; echo $var_char; ?>
The output of the implementation of this code is the result:
As you can see from this example, the variable name begins with $, indicating that it is a variable. Variable names start with a letter (az, AZ) or an underscore _ followed by any letter or number and underscores, but not spaces.
These variable names are valid as follows:
$var_char $varChar $_varChar $var_char5
For variable naming, recommend that variable names be preferred to indicate a combination of their actual semantics, such as $my_name or $myName.
Unlike a strongly typed programming language such as C, PHP is a loosely typed language that does not need to be declared before setting a variable. Depending on how the variable is set, PHP automatically converts the variables to the correct data type, and the variables are automatically declared when they are used. This property gives Web programming great flexibility.