Variables in PHP
Variables are used to store values, such as numbers, text strings, or arrays.
Once a variable is set, we can use it repeatedly in the script.
In PHP, you do not need to declare a variable before you set it.
All variables in PHP start with the $ symbol.
For example:
$myValue = 1;
In PHP, variable names and variable values are stored in different memory spaces, and a variable value can be represented by several different variable names.
Variable values can also be used as variable names.
For example:
<? PHP $myValue = ' abc '; $myOutput = ' myvalue '; Echo $$myOutput;? >
The results shown are:
Abc
The resulting floating-point result in PHP is not equal to the result of a floating-point variable, because the result of the operation is an approximate (imprecise)
For example:
<?PHP$a= 0.9;$b= 0.3;$c= 0.6;if(($a-$b)==$c)Echo $a,‘-‘,$b, "equals",$c;ElseIf(($a-$b)!=$c)Echo $a,‘-‘,$b, "Not equal to",$c;?>
The result is:
0.9-0.3 Not equal to 0.6