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.
Snippet of Utils.php
:
class Utils {
public $config;
public function __construct($config) {
$this->config = json_decode(json_encode($config));
}
Snippet of System.php
:
require_once("Utils.php");
class System extends Utils {
// a bunch of functions
public function bind($port) {
// stuff
$this->writeOutput("Host: {$this->config->MySQL->Host}");
Snippet of Game.php
:
require_once("Config.php");
$utils = new Utils($config);
What Config.php is a bit like:
$config = array(
"array" => array(
"Key" => "Value",
"Key2" => "Value"
),
"anotherarray" => array(
"AnotherKey" => "AnotherValue",
"ItsAnArray" => array("key" => "value"),
),
);
It's saying the errors are with every use of $this->config in System.php. What am I doing wrong?