title: PHP Array to JSON: Trying to get property of a non-object error
body: <p>I'm getting "trying to get a property of a non-object" when I'm trying to get values from an array I converted to JSON.</p>
  
  <p>Snippet of <code>Utils.php</code>:</p>
  
  <pre><code>class Utils {
  
      public $config;
  
      public function __construct($config) {
          $this-&gt;config = json_decode(json_encode($config));
      }
  </code></pre>
  
  <p>Snippet of <code>System.php</code>:</p>
  
  <pre><code>require_once("Utils.php");
  class System extends Utils {
  // a bunch of functions
  public function bind($port) {
  // stuff
  $this-&gt;writeOutput("Host: {$this-&gt;config-&gt;MySQL-&gt;Host}");
  </code></pre>
  
  <p>Snippet of <code>Game.php</code>:</p>
  
  <pre><code>require_once("Config.php");
  $utils = new Utils($config);
  </code></pre>
  
  <p>What Config.php is a bit like:</p>
  
  <pre><code>$config = array(
  
  "array" =&gt; array(
      "Key" =&gt; "Value", 
      "Key2" =&gt; "Value"
  ),
  
  "anotherarray" =&gt; array(
      "AnotherKey" =&gt; "AnotherValue", 
      "ItsAnArray" =&gt; array("key" =&gt; "value"),
  ),
  
  );
  </code></pre>
  
  <p>It's saying the errors are with every use of $this->config in System.php. What am I doing wrong?</p>