简体   繁体   中英

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

In my config.ini file given

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

I tried to access it in zend action helper function as

$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

ERROR: Call to a member function toArray() on a non-object

How to correct this problem?

EDIT:

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

In zend action helper function

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

Above print_r statement gives me a correct array. How this happens?

I've just tried your code. It works fine. It looks like you don't set customer.login.support[] .

This can happen if you load another section of config file (eg testing instead of development ) which also have customer.login.test but doesn't have customer.login.support[]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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