How to retrieve parameters from Zend application.ini file during the session? [duplicate]

Deadly 提交于 2019-12-04 01:59:35

Using Zend_Controller_Front, you can retrieve information from application.ini from anywhere in your application (controller, plugin, models etc) using code like this:

$config = Zend_Controller_Front::getInstance()->getParam('bootstrap');

Say in application.ini you had some options like this:

apikeys.google.maps.id  = "abc"
apikeys.google.maps.key = "123456789"
apikeys.twitter.oauth   = "20jg9032jg9320gj30"

You can then access those values using the above $config variable:

$apikeys = $config->getOption('apikeys');
$mapsId  = $apikeys['google']['maps']['id'];  // abc
$maksKey = $apikeys['google']['maps']['key']; // 123456789
$twitKey = $apikeys['twitter']['oauth'];      // 20jg9032jg9320gj30

Hope that helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!