Zend Framework - need to access a GET parameter from a view

后端 未结 5 2752
梦谈多话
梦谈多话 2021-02-20 16:00

I am using the Zend framework and what I need is to construct a url in my view. Normally in regular php code I\'d just grab the GET Variable by using the global $_GET. However w

5条回答
  •  被撕碎了的回忆
    2021-02-20 16:26

    To access a request variable direct in the view you could do:

    Zend_Controller_Front::getInstance()->getRequest()->getParam('key');
    

    But as others have said, this is not a good idea. It may be easier, but consider other options:

    • set the view variable in the controller
    • write a view helper that pulls the variable from the request object

提交回复
热议问题