PHP   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php – Zend框架:在引导中获取请求对象大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如何从引导文件内部获取请求对象?

我可以尝试这种方法,但不能工作.

$request= new Zend_Controller_request_http();
$request = Zend_Controller_FrontController::geTinstance()->getrequest();
如果你真的想要,你可以实现这个呼叫:
public function _initrequest()
{
    $this->bootstrap('frontController');
    $front = $this->getresource('frontController');
    $front->setrequest(new Zend_Controller_request_http());

    $request = $front->getrequest();
}

但是,应该避免这种情况,因为在调用前端控制器(例如模块,控制器或动作名称)之后,Response对象所需的大部分数据都将可用.

存储在Response对象中的其他变量从全局数组(例如$_SERVER,$_POST或$_GET)中提取,您可以直接在引导中直接读取.

但是很可能你想在front controller plugin中使用Response对象:

class Your_Controller_Plugin_PluginName extends Zend_Controller_Plugin_Abstract
{
     public function predispatch(Zend_Controller_request_Abstract $request)
     {
         // do anything with the $request here
     }
}

大佬总结

以上是大佬教程为你收集整理的php – Zend框架:在引导中获取请求对象全部内容,希望文章能够帮你解决php – Zend框架:在引导中获取请求对象所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。