I tried creating an object in PHP for PHPMailer to be used in development enviroments.
class Configuration
function __construct()
{
// creating an object for configuration, setting the configuration options and then returning it.
return $config = (object) array(
'DevEnv' => true, // DevEnv setting is used to define if PHPMailer should use a dev mail address to send to or not.
'ReceiverEmail' => 'email@gmail.com', // Set the develop enviroment email.
'ReceiverName' => 'name' // Set the develop enviroment email name.
);
}
}
Then I call the class in another controller:
protected $configuration;
function __construct()
{
$this->configuration = new Configuration();
}
function SendInfoMail()
{
foreach($this->configuration as $config) {
var_dump($config);
if ($config->DevEnv == true) {
// do stuff
}else{
// do stuff
}
}
for some reason, it just dumps an empty object. I also tried using
var_dump($config->ReceiverEmail);