PHP and MySQL Basics: Variables
Posted by Daniel at 10:37 pm
Variables are the building blocks of any programming language. in PHP variables are very important, it used to store numeric or non-numeric datas. PHP supports different types of variable types (Booleans, Integers, Floating point numbers, Strings, Arrays, Objects, resources and nulls.
PHP VARIABLE NAMING RULES:
- PHP variables starts with a $ sign : example. $daniel
- $ sign is followed by a letter or an underscore. thus $123 is not a valid PHP variable.
- it can contain letters, numbers, underscores or even dashes.
- no spaces
- PHP variables are CASE-SENSITIVE thus $daniel and $DANIEL are completely different variable.
EXAMPLES OF VALID PHP VARIABLES
$dan
$Daniel
$myVariable – Camel case style
$my_variable
$my-variable
$item1
$_note
$__noteBook