illustrate
1. The declaration of a variable in PHP must be represented by a dollar sign followed by the variable name, and the assignment operator (=) is used to assign a value to the variable.
2. If most PHP variables are not declared in a function, they can only be used in a separate scope at the end of the file where they are declared.
This single range span can be between the start tag and the end tag.
Example
<?php $var = ''; // Declare a variable $var and assign an empty value if(empty($var)){ // The result is true because $var is empty echo "$var is either 0 or not set at all" ; } if(!isset($var)){ // The result is false because $var has been set echo "$var is not set at all"; } unset($var); // Release variable $var in memory if(isset($var)){ // The result is false, the variable $var has been released previously, and $var no longer exists echo "This var is set so I will print"; }
The above is the method of declaring variables in PHP. I hope it will be helpful to everyone.