Using Variables in PHP
Using Variables in PHP
variable
A variable is simply a container thats used to store both
numeric and non-numeric information.
PHP has some simple rules for naming variables.
Every variable name must be preceded with a dollar ($) symbol
and must begin with a letter or underscore character, optionally
followed by more letters, numbers, or underscore characters.
Common punctuation characters, such as commas, quotation
marks, or periods, are not permitted in variable names; neither
are spaces.
examples
for example, $root, $_num, and $query2 are
all valid variable names, while $58%, $1day,
and email are all invalid variable names.
Destroying Variables
To destroy a variable, pass the variable to PHPs aptly
named unset() function, as in the following example:
<?php
// assign value to variable
$car = 'Porsche';
// output: 'Before unset(), my car is a Porsche'
echo "Before unset(), my car is a $car";
// destroy variable
unset($car);
// this will generate an 'undefined variable' error
// output: 'After unset(), my car is a '
echo "After unset(), my car is a $car";
?>
THANK YOU