Zend Framework:如何调用在引导程序中创建的自定义函数?
我正在使用 Zend Framework v 1.10
我在引导文件中创建了一个自定义函数:
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function init(){ }
public function helloworld(){ echo 'hello';}
}
?>
How do I call the helloworld() function from an Action inside the Index Controller?
任何帮助将不胜感激。
谢谢
I am using Zend Framework v 1.10
I have created a custom function in the bootstrap file:
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function init(){ }
public function helloworld(){ echo 'hello';}
}
?>
How do I call the helloworld() function from an Action within the Index Controller?
Any help will be appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
应该有效。但我想不出你想要这样做的任何原因 - 引导程序用于初始化应用程序资源,它的工作早在控制器介入之前就完成了。也许您在方法中所做的任何事情都应该是资源或控制器插件中?
should work. But I can't think of any reason why you would want to do this - the bootstrap is for initialising application resources, its job is done long before controllers get involved. Perhaps whatever you are doing in the method should be a resource or in a controller plugin?
任何人都可以调用引导类中的函数,而无需创建该类的任何对象。 Bootstrap 自动调用以
_init
关键字作为前缀的自定义函数。例如:Anyone can call a function in the bootstrap class without making any object of the class. Bootstrap automatically calls custom functions which have the
_init
keyword as a prefix. Such as:您在引导程序中创建的以
_init
开头的任何公共函数都将由引导代码自动调用。例如:Any public functions you create in the bootstrap that begin with
_init
will automatically be called by the bootstrapping code. For instance: