Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ZendFramework-如何知道执行哪个控制器和哪个特定方法?_Php_Zend Framework_Zend Controller - Fatal编程技术网

Php ZendFramework-如何知道执行哪个控制器和哪个特定方法?

Php ZendFramework-如何知道执行哪个控制器和哪个特定方法?,php,zend-framework,zend-controller,Php,Zend Framework,Zend Controller,当我执行/mycontroller/search时,它只显示/mycontroller,但是 在搜索方法中如何获取/mycontroller/search,在其他方法中如何获取/mycontroller/other $this->getRequest->getActionName;返回操作名称。 您还可以使用$\u SERVER['REQUEST\u URI']获取所需内容。$this->getRequest->getActionName;返回操作名称。 您还可以使用$\u SERVER['RE

当我执行/mycontroller/search时,它只显示/mycontroller,但是 在搜索方法中如何获取/mycontroller/search,在其他方法中如何获取/mycontroller/other

$this->getRequest->getActionName;返回操作名称。 您还可以使用$\u SERVER['REQUEST\u URI']获取所需内容。

$this->getRequest->getActionName;返回操作名称。 您还可以使用$\u SERVER['REQUEST\u URI']来获取所需内容。

您为什么希望/mycontroller/search来自此:

public function searchAction() { 
   $this->url .= "/" . $this->getRequest()->getControllerName();
   echo $this->url; // output: /mycontroller
                    // expect: /mycontroller/search
   exit;
  }
您只需要控制器

这将有助于:

 public function searchAction() { 
    $this->url = '/'. $this->getRequest()->getControllerName();
    $this->url .= '/' . $this->getRequest()->getActionName();

    echo $this->url; // output: /mycontroller/search

    echo $this->getRequest()->getRequestUri(); //output: requested URI for comparison

    //here is another way to get the same info
    $this->url = $this->getRequest()->controller . '/' . $this->getRquest()->action;
    echo $this->url;

 exit;
 }
为什么您希望/mycontroller/search来自:

public function searchAction() { 
   $this->url .= "/" . $this->getRequest()->getControllerName();
   echo $this->url; // output: /mycontroller
                    // expect: /mycontroller/search
   exit;
  }
您只需要控制器

这将有助于:

 public function searchAction() { 
    $this->url = '/'. $this->getRequest()->getControllerName();
    $this->url .= '/' . $this->getRequest()->getActionName();

    echo $this->url; // output: /mycontroller/search

    echo $this->getRequest()->getRequestUri(); //output: requested URI for comparison

    //here is another way to get the same info
    $this->url = $this->getRequest()->controller . '/' . $this->getRquest()->action;
    echo $this->url;

 exit;
 }