What’s a variable in PHP?

A variable in PHP can contain a certain value and is indicated with a name which is always preceded by a Dollar sign. So a variable starts with a Dollar sign, immediately followed by the variable’s name, on its turn followed by an equal sign and next the variable’s value. Finally, the complete variable is closed off by means of a semicolon (for example $a = "text"; where the variable’s name is ‘a’ and the value is ‘text’). The variable’s value can change, while the variable’s name will always remain the same. The variable can be used as a placeholder for changing (variable) data. For that reason a variable is also called a named value.



Was this useful?