English 中文(简体)
如何获取泽斯德角助老会的卢尔变量的价值?
原标题:How to access the value of a url variable in a Zend view Helper?

我认为,我想获得具体变数(湿租赁)的价值。 我如何能够这样做?

我能够用我的控制名称:Zend_Controller_Front:getInstance()->getRequest()->getControllerName();但我对变数没有想法......

提前感谢!

最佳回答

最明显的是:

// will retrieve any param set in the request (might even be route param, etc)
Zend_Controller_Front::getInstance()->getRequest()->getParam(  someParam  );

// $_POST
Zend_Controller_Front::getInstance()->getRequest()->getPost(  somePostParam  );

// $_GET
Zend_Controller_Front::getInstance()->getRequest()->getQuery(  someQueryStringParam  );

Also have a look at the API docs:
General
Zend_Controller_Request_Http (1.10)

问题回答

可在<代码>Zend_Controller_Front上查阅申请标本:

abstract class App_View_Helper_Abstract extends Zend_View_Helper_Abstract
{
   /**
    * @var Zend_Controller_Front
    */
   private $_frontController;

   /**
    * Convience function for getting a request parameter from the request
    * object in a view helper
    * @param string $name The name of the request parameter
    * @param mixed $default The value to return if $name is not defined in the
    * request
    * @return mixed The value of parameter $name in the request object,
    * or $default if $name is not defined in the request
    */
   public function getRequestVariable ($name, $default = null)
   {
      return $this->getRequest()->getParam($name, $default);
   }

   /**
    *
    * @return Zend_Controller_Request_Abstract
    */
   public function getRequest ()
   {
      return $this->getFrontController()->getRequest();
   }

   /**
    * @return Zend_Controller_Front
    */
   private function getFrontController ()
   {
      if ( empty($this->_frontController) )
      {
         $this->_frontController = Zend_Controller_Front::getInstance();
      }
      return $this->_frontController;
   }
}

现在你可以使用<代码>植被重建 不同观点的助推器 App_View_Helper_Abstract





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签