Php ZendFramework-如何知道执行哪个控制器和哪个特定方法?
当我执行/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来自此: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
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;
}