I'm fairly new to PHP so sorry if this is a naive question, but I want to build a php function library that utilizes a variable that is global across multiple pages. I'm using these 3 files to test:
functions.php
<?php
    function report()
    {
        echo "Value = ".$GLOBALS["var"]; 
    }
?>
index.php
<?php
    $var = "ABC";
    require "functions.php";
    echo "<h1>index.php</h1>";
    report();
?>
<br /><br />
<input type=button onClick="location.href='page2.php'" value="Page2">
page2.php
<?php   
    require "functions.php";
    echo "<h1>page2.php</h1>";
    report();
?>
The report function called by index.php echoes Value = ABC as expected. But when the Page2 button is clicked, the report function called by page2.php displays an Undefined index error raised by $GLOBALS["var"] in functions.php. 
I'd like to use $GLOBALS["var"] when it is referenced from page2.php. Can anyone tell me how to enable this? Thanks for any help!
 
     
     
     
    