gpt4 book ai didi

Cakephp博客教程错误

转载 作者:行者123 更新时间:2023-12-02 14:40:44 26 4
gpt4 key购买 nike

我是 cakephp 新手。我关注了这个http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html教程中,除了“编辑方法”之外,当我单击编辑链接时,它会给出以下警告消息并且不会编辑,一切都工作正常。

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'))

导致问题的调用,如CakeRequest::is()只能采取array从 CakePHP 2.4.0 开始,早期版本预计 string .

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

$this->request->is('post') || $this->request->is('put')

另请参阅

关于Cakephp博客教程错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19710324/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com