Php 有人能解释一下$this->;请求->;参数[0];?

Php 有人能解释一下$this->;请求->;参数[0];?,php,cakephp,Php,Cakephp,我在cakephp网站上关注本教程。我被这件事难住了 public function isAuthorized($user) { // All registered users can add posts if ($this->action === 'add') { return true; } if (in_array($this->action, array('edit', 'delete'

我在cakephp网站上关注本教程。我被这件事难住了

public function isAuthorized($user) {
        // All registered users can add posts
        if ($this->action === 'add') {
            return true;
        }

        if (in_array($this->action, array('edit', 'delete'))) {
            $postId = $this->request->params['pass'][0]; //what is this?

            if ($this->Post->isOwnedBy($postId, $user['id'])) {
                return true;
            }
        }
        return parent::isAuthorized($user);
    }
这是什么意思?我知道$this指的是控制器,但param['pass']是什么,它们在哪里以及如何得到它

$postId = $this->request->params['pass'][0];

这些是在请求字符串或Post变量中传递的参数

CakereRequest公开了几个用于访问请求的接口 参数。第一个是对象属性,第二个是数组 索引,第三个是通过$this->request->params:


不确定这是否是最好的答案,但我所要做的就是返回false

if ($this->Post->isOwnedBy($postId, $user['id'])) {
                return true;
            }else {
                return false;
            }

有什么方法可以记录$this->request->params['pass'][0];路过吗?使用cakephp调试工具包?@artSir是的,您应该在调试工具包栏中看到它。好吧,它可能解决了您遇到的问题,但它肯定不是您自己问题的答案,您要求解释一个变量,前面提供的答案是,您应该接受这个答案。