June 2002
Intermediate to advanced
800 pages
16h 3m
English
Variables cannot be “seen” in the entire application. This is a very important issue because otherwise programmers would easily run into trouble. Especially when building huge applications, it is important to know where which variables can be seen and used.
Let's start with a simple example:
<?php
$a = "Hello World";
echo "main: $a<br>\n";
display_data();
function display_data()
{
echo "display data: $a<br>\n";
}
?>
First, $a is initialized and displayed on the screen. Then display_data is called, which tries to display $a again:
main: Hello World display data:
As you can see, display_data displays nothing because $a cannot be seen by the function. $a has been initialized in the main function and therefore it is not ...
Read now
Unlock full access