Displaying ./code/PHP/simple/scope.php#!/usr/bin/php
<?php
$global = "This is global";
// $param is local to the function:
function foo($param) {
// Globals must be explicitly declared global inside of functions:
// This does not apply to super-globals, such as $_POST, $_GET
global $global;
$local = "This is local to this function";
echo $global . "\n";
}
foo("stuff");
?>
|