php - ZendFramework - 如何知道执行了哪个 Controller 和哪个特定方法?

标签 php zend-framework zend-controller

当我执行/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/

相关文章:

php - Zend 2 为 Controller 定义错误页面

javascript - Laravel:更改文本框编辑上的元素

php - 在 php 中使用 Decorator 的完整继承行为

zend-framework - Zend不同的 View 脚本?

php - Zend_Mail_Storage_Pop3::removeMessage 不起作用

mysql - 授予用户访问权限

php - Zf3 Controller 无法访问位于另一个模块中的模型类表

php - App Engine PHP 上传错误

php - Elasticsearch:多个小查询与一个较大查询 - 效率?

mongodb - 是否可以在 I5/OS 或 IBMi 服务器上安装 MongoDB?