title: Template class stops another class from working
body: <p>Trying to get a simple template system working, but it seems to affect another class.  </p>
  
  <p>I have two PHP classes, both called in index.php:  </p>
  
  <ul>
  <li>HeaderData.php - class allows user to setup Header data, eg doctype,
  charset.</li>
  <li>PageTemplates.php - class allows user to include a template file.</li>
  </ul>
  
  <p>When I call the HeaderData class, then <em>manually</em> <code>require()</code> a template file from view (ie contains doctype, head, meta tags etc), the code from the header class works fine in the template file, outputting the objects from the header class such as Doctype etc.  </p>
  
  <p>However, when I try to use the PagesTemplate class to include the template file (with manual <code>require()</code> removed from index.php), the template file is included, but the HeaderData class no longer works in it.<br>
  Error log shows:  </p>
  
  <ul>
  <li>Notice: "Undefined variable varHeaderData";</li>
  <li>Error: "Call to a member function PageDoctype() on a non-object";</li>
  </ul>
  
  <p>Both the variable and function worked fine when manually <code>require()</code> the template file in index.php.  </p>
  
  <p>The code below is dev only (data checks etc to be added):  </p>
  
  <p><strong>index.php:</strong>  </p>
  
  <pre><code>// Use HeaderData Class
  $varHeaderData = new HeaderData( 
                              array(  
                                     'PageDoctype' =&gt; '&lt;!DOCTYPE html&gt;',
                                     'PageCharset' =&gt; 'UTF-8', 
                                    ));
  
  // Use PageTemplates Class
  $varPageTemplate = new PageTemplates();
  $varPageTemplate-&gt;LoadTemplate('template-file.php');
  </code></pre>
  
  <p><strong>PageTemplates.php Class:</strong></p>
  
  <pre><code>class PageTemplates
    {
  
      private $strTemplatesDir = 'view/templates/';
  
      public function __construct($strTemplatesDir = NULL)
        {
          if ( is_dir($strTemplatesDir) )
            {
              $this-&gt;strTemplatesDir = $strTemplatesDir;
            }
        }
  
  
      public function LoadTemplate($strTemplateFile)
        {
           {
             require_once ($this-&gt;strTemplatesDir.$strTemplateFile);
           }
        }
  
    }
  </code></pre>
  
  <p><strong>template-file.php:</strong>  </p>
  
  <pre><code>echo $varHeaderData-&gt;PageDoctype();  
  </code></pre>
  
  <p>The HeaderData class simply sets the object the user entered in the array with the <code>PageDoctype()</code> function in the class (again this works fine without the page template class)</p>
  
  <p>Can someone tell me why when using the template class to <code>require()</code> the template file, it stops the objects from the HeaderData from working in the template-file.php?  </p>