PHP does not require a command to declare a variable, and the data type is determined by the value assigned to the variable.
$x $y echo echo
|
PHP supports the following data types:
To determine the data type of a variable, use the var_dump() function.
The var_dump() function provides both the data type and the value.
$x |
Check what var_dump() returns for different data types:
var_dump(5); |
To assign a string to a variable, use the variable name followed by an equal sign and the string.
$x |
You can assign the same value to multiple variables in a single line.
All three variables receive the value “Fruit”:
$x |