title: Centralize php globals?
body: <p>I have a functions.php file that, among other functions, includes the following:</p>
  
  <pre><code>function head() {
      global $brand, $brandName, $logo, $slogan, $siteName, $title, $titles, $keyword, $keywords, $description, $descriptions, $bodyclass, $bodyClass, $page;
      include('_assets/inc/head.php');
  }
  
  function foot() {
      global $brand, $brandName, $logo, $slogan, $siteName, $title, $titles, $keyword, $keywords, $description, $descriptions, $bodyclass, $bodyClass, $page;
      include('_assets/inc/foot.php');
  }
  </code></pre>
  
  <p>I needed to duplicate the globals line into the <code>foot()</code> to get variables I was calling in the  foot.php to display.  Isn't there a place for me to centralize these globals so I only need to place the global line once in my site?</p>
  
  <hr>
  
  <p>As per Jack's directions, I now have:</p>
  
  <pre><code>class Page {
      private $context;
      public function __construct(array $context) {
          $this-&gt;context = $context;
      }
      public function printHead() {
          extract($this-&gt;context);
          include '_assets/inc/head.php';
      }
      public function printFoot() {
          extract($this-&gt;context);
          include '_assets/inc/foot.php';
      }
  }
  $page = new Page(array(
      'brand' =&gt; 'myBrand',
      'brandName' =&gt; '&lt;span class="brand"&gt;'.$brand.' &lt;sup&gt;&lt;span aria-hidden="true" class="icon_search"&gt;&lt;/span&gt;&lt;/sup&gt;&lt;/span&gt;',
      'logo' =&gt; '&lt;a href="/" class="brand"&gt;'.$brandName.'&lt;/a&gt;',
      'slogan' =&gt; '&lt;span class="slogan"&gt;Find A Real Estate Professional&lt;/span&gt;',
      'siteName' =&gt; $logo.' | Directory of Real Estate Professionals',
      'title' =&gt; 'Directory of Real Estate Professionals | '.$brand.'',
      'titles' =&gt; array (
          'home' =&gt; 'Find A Real Estate Professional | '.$brand.''
      );
          if(isset($titles[$page])){
              $title = $titles[$page];
          }
      'keyword' =&gt; ''.$brand.', real estate professionals, real estate directory, real estate agents, realtor directory, real estate brokers, real estate lawyers, real estate insurance agents, real estate appraisers, real estate staging consultants',
      'keywords' =&gt; array (
          '' =&gt; ''
      );
          if(isset($keywords[$page])){
              $keyword = $keywords[$page];
          }
      'description' =&gt; ''.$brand.' is a complete directory of real estate professionals, including agents, brokers, appraisers, insurance agents, stagers, lawyers, and more.',
      'descriptions' =&gt; array (
          '' =&gt; ''
      );
          if(isset($descriptions[$page])){
              $description = $descriptions[$page];
          }
      'bodyclass' =&gt; ' page bbfix',
      'bodyClass' =&gt; array (
          'home' =&gt; 'home'
      ); 
          if(isset($bodyClass[$page])){
              $bodyclass = $bodyClass[$page];
          }
      'page' =&gt; $page
  ));
  $page-&gt;printHead();
  $page-&gt;printFoot();
  </code></pre>
  
  <p>However, my code has errors relating to the arrays. :(</p>