Global access of PHP vars
<p>I looked into past answers and was led to believe PHP variables assigned in a header file are global.  I must be
doing something wrong then.  Here's a much-simplified version of my code:</p>

<p><strong>This is my myGlobals.php file:</strong></p>

<pre><code>&lt;?php

  $NAMELABEL = "Name";

?&gt;
</code></pre>

<p><strong>This is file index.php that 'requires' myGlobals.php then calls a function in a 3rd php file</strong></p>

<pre><code>&lt;?php

   require_once 'myGlobals.php';
   require_once 'DisplayRecords.php'; 

   displayRecords(); 
?&gt;
</code></pre>

<p><strong>And here is DisplayRecords.php</strong></p>

<pre><code>&lt;?php

  function displayRecords()
 {
    echo '&lt;table border="1"&gt;';
    echo '&lt;tr&gt;';
    echo '&lt;th&gt;' . $NAMELABEL . '&lt;/th&gt;';
    echo '&lt;/tr&gt;';
    echo "&lt;/table&gt;";
  }
?&gt;
</code></pre>

<p>This is HIGHLY simplified, only the code causing the error.</p>

<p>The error msg. I get when I run it is:</p>

<blockquote>
  <p>Notice: Undefined variable: NAMELABEL
  in
  C:\xampp\htdocs\fbreverse\DisplayRecords.php
  on line 29</p>
</blockquote>

<p>Now, before I changed to the global variable $NAMELABEL -- I used this and it worked fine:</p>

<pre><code>   echo '&lt;th&gt;Name&lt;/th&gt;';
</code></pre>

<p>by 'fine' I mean that the table was created and it had a header called <strong>Name</strong> as on of the columns.</p>

<p>NOTE:  using single quotes around the html tags above is allowed, and needed if you use a double-quoted string
in the tag, as I did in <code>echo '&lt;table border="1"&gt;'</code>  -- so I just stayed consisted and stuck with the single quote.
Changing the above example to </p>

<pre><code> echo "&lt;th&gt;" . $NAMELABEL . "&lt;/th&gt;";
</code></pre>

<p>made zero difference, same error message,   <em>Notice: Undefined variable: NAMELABEL in C:\xampp\ht........blah blah</em></p>

<p>Why isn't <code>$NAMELABEL</code> visible in the function <code>displayRecords()</code> inside DisplayRecords.php?</p>
