Variables in PHP are extremely flexible. They allow you to store data easily across your entire site for long periods of time, but at the same time can be temporary if you wish it so. They only exist for the duration of the script. Once a new script is called, all existing variables and the data bound to them is erased, unless you take certain steps to make alter their longevity.
PHP has some predefined variables, $globals is on of them.
Let’s write a short script to show us the use of variables.
<?php
print_r ($GLOBALS);
?>
After we open the tags, the print_r() function is called to make it a little more user friendly and more appealing to the eyes, a more human-readable format. We pass the predefined variable $GLOBALS to print_r(), and you should get a long page full of arrays.
The results will be different on every server because each server has it’s own configuration.
Variable Syntax:
And that about sums it up for now! I’ll write more about arrays, different types of strings, quotation marks and that good stuff very soon.
Thanks for choosing Viper Creations!