Learning PHP and MySQL
Example 03-08 Using a global variable changes the result
<?php
// Define a function function birthday(){
// Define age as a global variable
global $age;
// Add one to the age value
// set age to 30
$age = 30;
// Call the function birthday();
// Display the age echo $age;
?>
Displays:
31
Posted by on 07/19 at 03:40 PM
Next entry: Example 03-09 A static variable remembering its last value
Previous entry: Example 03-07 The default handling of variable scope