Zend框架talk.I簡稱Zend公司的config.ini參數知道:從腳本
"When referring to configuration parameters within a script,
you'll prefix it with $this->config and converting the periods
to right-facing arrows"
問題:然而,當我嘗試回聲「$這個 - > config->網站 - >網址; 「我沒有輸出。
如果我嘗試使用「$ this-> config [website] [url]」我會收到正確的輸出。
我在哪裏錯了?
我:
我引導類:
[..]
protected function _initConfig()
{
$config =$this->getOptions();// contents of config file
Zend_Registry::set('config', $config);
return $config;
}
protected function _initAction()
{
Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH."\My\Helper",'My_Action_Helper');
Zend_Controller_Action_HelperBroker::getStaticHelper('Initializer');
}
我My_Action_Helper_Initializer:
class My_Action_Helper_Initializer extends Zend_Controller_Action_Helper_Abstract
{
public function init()
{
$controller=$this->getActionController();
$controller->config=Zend_registry::get('config');
}
}
我的IndexController:
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
echo $this->config[website][url];//it outputs the correct value
echo $this->config->website->url;//NO OUTPUT!
}
}
感謝
盧卡
$ config = new Zend_Config($ this-> getOptions(),true);是重要的一點。 – piddl0r 2011-05-12 14:36:06