【问题标题】:Getting an error on accessing an array from ini file to zend framework从ini文件访问数组到zend框架时出错
【发布时间】:2012-08-28 06:45:09
【问题描述】:

在我的 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 上面的语句给了我一个正确的数组。这是怎么发生的?

【问题讨论】:

  • 检查配置文件,如果完全没问题,代码。

标签: php zend-framework ini zend-config


【解决方案1】:

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

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

【讨论】:

  • 不,我有customer.login.support[] 开发部分本身。如果我尝试使用support[],效果很好。
猜你喜欢
  • 2011-07-08
  • 1970-01-01
  • 2011-04-14
  • 2015-10-02
  • 2012-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-09
相关资源
最近更新 更多