当我执行/mycontroller/search 时,它只显示“/mycontroller”,但是
当我在 search
方法中时如何获取“/mycontroller/search”,当我在 other
方法中时如何获取“/mycontroller/other”。
class Mycontroller extends Zend_Controller_Action
{
private $url = null;
public function otherAction() {
$this->url .= "/" . $this->getRequest()->getControllerName();
echo $this->url; // output: /mycontroller
exit;
}
public function searchAction() {
$this->url .= "/" . $this->getRequest()->getControllerName();
echo $this->url; // output: /mycontroller
// expect: /mycontroller/search
exit;
}
}
最佳答案
$this->getRequest()->getActionName();
返回操作名称。
您还可以使用 $_SERVER['REQUEST_URI']
来获取您想要的内容。
关于php - ZendFramework - 如何知道执行了哪个 Controller 和哪个特定方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9148854/