- var_dump: documentation ( source)
<?php
class Container {
protected $s=array();
function __set($k, $c) { $this->s[$k]=$c; }
function __get($k) { return $this->s[$k]($this); }
}
$c = new Container();
// parameters
$c->mailer_class = function () { return 'Zend_Mail'; };
$c->mailer_username = function () { return 'fabien'; };
$c->mailer_password = function () { return 'myPass'; };
// objects / services
$c->mailer_transport = function ($c) {
return new Zend_Mail_Transport_Smtp(
'smtp.gmail.com',
array(
'auth' => 'login',
'username' => $c->mailer_username,
'password' => $c->mailer_password,
'ssl' => 'ssl',
'port' => 465,
)
);
};
$c->mailer = function ($c) {
var_dump($c->mailer_class());
exit;
$obj = new $c->mailer_class();
$obj->setDefaultTransport($c->mailer_transport);
return $obj;
};
// get the mailer
$mailer = $c->mailer;