Cakephp博客教程错误

Cakephp博客教程错误,cakephp,Cakephp,我是cakephp新手。我遵循了本教程,当我单击编辑链接时,除了“编辑方法”之外,其他一切都正常工作,它会给出以下警告消息,并且不会进行编辑 Warning (2): strtolower() expects parameter 1 to be string, array given [CORE/Cake/Network/CakeRequest.php, line 471] Code Context $type = array( (int) 0 => 'post', (in

我是cakephp新手。我遵循了本教程,当我单击编辑链接时,除了“编辑方法”之外,其他一切都正常工作,它会给出以下警告消息,并且不会进行编辑

Warning (2): strtolower() expects parameter 1 to be string, array given [CORE/Cake/Network/CakeRequest.php, line 471]
Code Context
$type = array(
    (int) 0 => 'post',
    (int) 1 => 'put'
)
$this = object(CakeRequest) {
    params => array(
        'plugin' => null,
        'controller' => 'posts',
        'action' => 'edit',
        'named' => array([maximum depth reached]),
        'pass' => array(
            [maximum depth reached]
        )
    )
    data => array()
    query => array()
    url => 'posts/edit/2'
    base => '/cake_2_0'
    webroot => '/cake_2_0/'
    here => '/cake_2_0/posts/edit/2'
}
strtolower - [internal], line ??
CakeRequest::is() - CORE/Cake/Network/CakeRequest.php, line 471
PostsController::edit() - APP/Controller/PostsController.php, line 48
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 485
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 186
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 161
[main] - 

为了进一步澄清这一点,它是

$this->request->is(array('post', 'put'))
导致问题的调用,因为自CakePHP 2.4.0起,
CakereRequest::is()
只能获取
数组
,早期版本需要
字符串

我不确定人们是否应该期望教程与旧版本兼容,但是,为了完整起见,在旧版本中,您必须使用多个调用
CakeRequest::is()

另见


PostsController.php
发布一些应该在
函数编辑()中的代码。
public function edit($id=null){if(!$id){throw new NotFoundException('Invalid Post');}$Post=$this->Post->findById($id);if(!$Post){throw new NotFoundException('Invalid Post')))}如果($this->request->is(数组('post','put')){$this->post->id=$id;如果($this->post->save($this->request->data)){$this->Session->setFlash('Your post has updated');返回$this->redirect(数组('action'=>'index');}$this->Session setFlash(__('Canable to update your post.');}如果(!$this->request->data){$this->request->data=$post;}}代码应该出现在问题中!顺便说一句,请始终提及您的确切CakePHP版本!(提示:问题与您使用的版本有关)谢谢你的帮助,它确实关心的版本。它实际上解决了我的问题。我使用2.2版本和以下教程2.4!
$this->request->is('post') || $this->request->is('put')