Simple variables
Generally a PHP variable has no need to be declared, as happens in other programming languages (like pascal).
| $a | $pippo | $a12 | $count | $ok | $mario_rossi |
A simple variable is like a box: the name of the variable, for example $var, is its identifying label.
The PHP assignment instruction puts a value inside the box:
| $var = 8; | $var is the label, the number 8 is the box content The = symbol doesn't mean equality, but assignment! |
A simple variable can hold only one value at a time: each new assignment deletes the previous one.
The variable types depend on their content. The simple variable types can be:
| $a = 13; | assignment of a numerical value to $a |
| $a = "giovanni"; | assignment of a string to $a |
| $a = TRUE; | assignment of the TRUE boolean constant to $a |
| $a = $a + 1; | increase of 1 the numerical value of $a |
| $a++; | equivalent instruction of $a = $a + 1; |
| $a = $a + $c; | assigns the sum of the numerical values $b and $c to $a |