title: How can I use PHP Class Method inside a function without using global variable?
body: <p>I am adding theme options to Wordpress and I have a <code>Theme_Options</code> class for this.</p>
  
  <p>Inside the class I have <code>get_field($field)</code> method to grab the theme option.</p>
  
  <p>I would like to create a function so I can use in the WordPress Theme that I am building to grab the theme option, but I do not want to use global variable.</p>
  
  <pre class="lang-php prettyprint-override"><code>class Theme_options
  {
      public function __construct()
      {
      }
  
      public function get_field($field) 
      {
          // logic to get the theme option
          return $field;
      }
  }
  </code></pre>
  
  <p>Right now I need to use <code>global $Theme_Options</code> to create <code>get_field()</code> function.</p>
  
  <pre class="lang-php prettyprint-override"><code>$Theme_Options = new Theme_Options();
  
  
  function get_field($field) {
      global $Theme_Options
      return $Theme_Options-&gt;get_field($field);
  }
  </code></pre>
  
  <p>How can I create <code>get_field()</code> function without using global variable inside that function?</p>