Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调用未定义的函数视图::fetch cakePHP_Php_Cakephp_Layout_View_Cakephp 2.0 - Fatal编程技术网

调用未定义的函数视图::fetch cakePHP

调用未定义的函数视图::fetch cakePHP,php,cakephp,layout,view,cakephp-2.0,Php,Cakephp,Layout,View,Cakephp 2.0,我开始尝试CakePHP 2.x版,在View/Layouts中创建了一个default.ctp布局文件,其中包含如下代码: echo $this->fetch('css'); 但我一直得到以下错误: Fatal error: Call to undefined method View::fetch() in C:\wamp\www\....... Fatal error: Call to undefined method View::start() in C:\wamp\www\..

我开始尝试CakePHP 2.x版,在View/Layouts中创建了一个default.ctp布局文件,其中包含如下代码:

echo $this->fetch('css');
但我一直得到以下错误:

Fatal error: Call to undefined method View::fetch() in C:\wamp\www\.......
Fatal error: Call to undefined method View::start() in C:\wamp\www\.......
我尝试在视图文件中为此css创建块,如下所示:

$this->start('css');
$this->Html->css('home_page', null, array('inline' => false));
$this->end();
但当我这样做时,我会得到以下错误:

Fatal error: Call to undefined method View::fetch() in C:\wamp\www\.......
Fatal error: Call to undefined method View::start() in C:\wamp\www\.......
需要帮忙吗


谢谢您

View::fetch()从2.1版开始提供,您的版本是什么?

我认为您不需要fetch、start、end来包含css,您可以使用:


$this->Html->css(array('home_page.css'));
//OR
echo $this->fetch('css'); //from version 2.1

参考资料:

这本书比发行版提前了一点!fetch()来自2.1代码,它仍然是alpha


尝试使用cake's bake tool生成默认布局,研究2.0是如何实现的,并确保在使用2.1代码库之前,不要遵循2.1中的新布局。

我刚才遇到了这个问题!我升级到2.1 alpha,试图让它重新工作。谢谢你的帮助!