I there a method to allow me to use an array as an object?
I have the following code in my main class
function __construct() { require 'config.php'; $this->config = new PHPSO_Config(); }
where the PHPSO_Config class looks something like this
class PHPSO_Config { /** * The administrators email address */ var $adminEmail = 'user@domain.tld'; //I'm using this email to test }
so can I accomplish the same thing and be able to access the config vars as an object without creating a second class?
You can cast an array to an object using
thus the following should work (untested):
then $class->config->username should work.