Declaring a global variable inside a function
<p>I have two PHP files.  In the first (join php) I set a cookie based on a $_GET value, and then call a function which then sends this value on to the other file.  This is some code which I'm using in join.php:</p>

<pre><code>    include('/inc/processJoin.php');
    setcookie("site_Referral", $_GET['rid'], time()+10000);
    $joinProc = new processJoin();
    $joinProc-&gt;grabReferral($_COOKIE["site_Referral"]);
</code></pre>

<p>The other file (processJoin.php) will then send this value (among others) to further files which will process and insert the data into the database.</p>

<p>The problem I'm having is that when the grabReferral function in processJoin.php is called, the $referralID variable isn't being defined on a global scale - other functions in processJoin.php can't seem to access it to send to other files/processes.</p>

<p>I've tried this in processJoin.php:</p>

<pre><code>    grabReferral($rid){
       global $ref_id;
       $ref_id = $rid;
    }

    someOtherFunction(){
       sendValue($ref_id);
    }
</code></pre>

<p>But the someOtherFunction can't seem to access or use the $ref_id value.  I've also tried using <code>define()</code> to no avail.  What am I doing wrong?</p>
