我把它放在我的application.ini文件中:
contact.email.address = "my.mail@bla.org"
contact.email.name = "Test Name"
然后在我的索引控制器上执行了操作:
$configOptions = $this->getInvokeArg('bootstrap')->getOptions();
$contactAddress = $configOptions->contact.email.address;
$this->view->contact = $contactAddress;
根据我的观点,我有:
var_dump($this->contact);
但我收到的是NULL。
我错过了什么?
答案 0 :(得分:5)
在你的控制器中,我想你想要:
$configOptions = $this->getInvokeArg('bootstrap')->getOptions();
$contactAddress = $configOptions['contact']['email']['address'];
$this->view->contact = $contactAddress;
答案 1 :(得分:2)
您可以使用:
$configOptions = new Zend_Config($this->getInvokeArg('bootstrap')->getOptions());
$contactAddress = $configOptions->contact.email.address;
$this->view->contact = $contactAddress;