Zend,Application.ini中的全局变量? [英] Zend, Global variable in Application.ini?
本文介绍了Zend,Application.ini中的全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题,因为我需要一个全局静态变量,我有问题可以将它添加到application.ini文件中,如何操作?
I have a question as I need to have a global static variable and I have question is any possibility to add it to the application.ini file, how to do it?
或者我必须:
Or I have to:
- 用静态变量创建抽象类,
- 注册它在Zend_Registry中可以从所有应用程序访问这个变量(在Bootstrap文件中注册它)
- 我可以使用它,或者更容易,我的意思是自动方式来做到这一点? / li>
- 我可以使用它,或者更容易,我的意思是自动方式来做到这一点? / li>
- Create abstract class with static variable,
- Register it in Zend_Registry to have access to this variable from all application (Register it in Bootstrap file)
- I can use it, or there is easier, I mean "automatic way" to do it?
感谢您的建议!
Regars,
Thanks for advice! Regars,
推荐答案
在Application.ini文件中
in Application.ini file
someservice.apikey = 12345678
someservice.passkey = 87654321
in bootstrap
in bootstrap
public function _initSomeservice()
{
$someservice = $this->getOption('someservice');
Zend_Registry::set('someservice', $someservice);
}
从注册表中拉出
to pull from Registry
$config = Zend_Registry::get('someservice');
这篇关于Zend,Application.ini中的全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文