| ||
Variables
Variables are for storing a values, such as text string "Hello World!" or the integer value 4. A variable can then be reused repeatedly, instead of typing out the value over and over again. PHP defines a variable with the following form: $variable_name =
Value;
Don't forget the dollar sign ($)at the beginning. It is similar to Algebra (parallel example) a=5 , b=2 ,c=4 a + b = 5 + 2 = 7 a x c = 5 x 4 = 20 a,b and c in Algebra are like variables in Php. A Quick Variable Example
In the example shown below variables ($hello, $a_number and $otherNumber) are given values by using an equal sign [ = ] PHP Code:
<?php $hello = "Hello World!"; $a_number = 4; $otherNumber = 8; ?>
PHP Variable Naming Conventions
Few rules needed to follow when choosing a name for your PHP variables.
Note |