title: Global vs static variables in PHP
body: <p>I'm creating a basic framework in PHP. I need to pass data for the current page into different functions, allow them to modify and save it, and then pass it back to the page to be displayed. I was originally planning on storing the data in a global variable like <code>$GLOBALS['data']</code>, but I'm starting to think that using a global is a bad idea. So I'm thinking that instead I will put a static variable in the system class, and access it using <code>system::$data</code>. So, my question is, which would be better and why?</p>
  
  <p>This:</p>
  
  <pre><code>$GLOBALS['data'] = array();
  $GLOBALS['data']['page_title'] = 'Home';
  echo $GLOBALS['data']['page_title'];
  </code></pre>
  
  <p>Or this:</p>
  
  <pre><code>class system
  {
      public static $data = array()
  }
  
  function data($new_var)
  {
      system::$data = array_merge(system::$data, $new_var);
  }
  
  data(array('page_title' =&gt; 'Home'));
  echo system::$data['page_title'];
  </code></pre>