繁体   English   中英

从ini文件访问数组到zend框架时出错

[英]Getting an error on accessing an array from ini file to zend framework

在我的config.ini文件中

customer.login.test = "test case" 
customer.login.support[] = "abel"
customer.login.support[] = "justin"
customer.login.support[] = "leon" 

我试图在zend action helper函数中访问它

$config = \Zend_Registry::get("config");
echo $config->customer->login->test; // Outputs as "test case"

print_r($config->customer->login->support); // No Result

print_r($config->customer->login->support->toArray()); // Gives Error

错误:在非对象上调用成员函数toArray()

如何解决这个问题?

编辑:

support[] = "abel"
support[] = "justin"
support[] = "leon" 

在zend动作助手功能中

print_r($config->support->toArray());

上面的print_r语句为我提供了一个正确的数组。 这是怎么发生的?

我刚刚尝试了您的代码。 工作正常。 好像您没有设置customer.login.support[]

如果您加载配置文件的另一部分(例如, testing而不是development ),而该部分也具有customer.login.test但没有customer.login.support[]则会发生这种情况

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM