可能是一个荒谬的问题,但有没有办法从控制器类本身获取实际的控制器名称?
喜欢
class SomeController extends Zend_Controller_Action {
public function init() {
$controllerName = $this -> getControllerName();
// And get "Some" as a output
}
}
Run Code Online (Sandbox Code Playgroud)
sil*_*lex 11
public function init() {
echo Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
}
Run Code Online (Sandbox Code Playgroud)
您可以使用请求获取控制器名称getControllerName().要获得请求(没有单身人士),您可以执行以下操作:
public function init() {
$controllerName = $this->_request->getControllerName();
// or
$controllerName = $this->getRequest()->getControllerName();
// or
$controllerName = $this->getFrontController()->getRequest()->getControllerName()
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8605 次 |
| 最近记录: |