title: Arguments to PHP template functions
body: <p>This is more of a style question. I have a template file <code>header.php</code> in which I define a <code>PrintHeader()</code> function.</p>
  
  <p>Callers of this function can specify, via global variables, the title of the page and any Javascript scripts to include when printing the header <em>(because surely not every page will have the same title or want to include the same scripts)</em>. I chose to use global variables rather than function arguments because the latter would require the interface to change when adding new arguments.</p>
  
  <p>Is this considered "good" style, and is there a "better" way to do what I'm trying to do?</p>
  
  <p><strong>header.php (simplified)</strong></p>
  
  <pre><code>&lt;?php
  function PrintHeader()
  {
    global $pageTitle, $scripts; // Set by the caller of this function
  
    echo &lt;&lt;&lt;HEADER
  &lt;html&gt;
   &lt;head&gt;
    &lt;title&gt;$pageTitle&lt;/title&gt;
  
  HEADER;
  
    if( !empty($scripts) )
    {
      foreach($scripts as $script)
      {
        echo "  &lt;script type=\"text/javascript\" src=\"$script.js\"&gt;&lt;/script&gt;\n";
      }
    }
  
    echo " &lt;/head&gt;\n";
  }
  ?&gt;
  </code></pre>
  
  <p><strong>index.php (simplified)</strong></p>
  
  <pre><code>&lt;?php
    $pageTitle = 'Welcome';
    $scripts = array('script1', 'script2');
    require('header.php');
    PrintHeader();
  
    // Print the rest of the page
  ?&gt;
  </code></pre>