元素&;获取cakephp2

元素&;获取cakephp2,cakephp,cakephp-2.0,Cakephp,Cakephp 2.0,cakephp2中的“fetch”和“element”有什么区别?我有这个密码 echo $this->fetch('meta'); echo $this->fetch('content'); 在default.ctp中,并且不知道它为什么在那里。我不能只使用$this->element('meta')并且必须在elements文件夹中创建meta.ctp 还有这个代码 echo $this->fetch('meta'); echo $this->fetch('

cakephp2中的“fetch”和“element”有什么区别?我有这个密码

 echo $this->fetch('meta');
echo $this->fetch('content');
在default.ctp中,并且不知道它为什么在那里。我不能只使用$this->element('meta')并且必须在elements文件夹中创建meta.ctp

还有这个代码

 echo $this->fetch('meta');
echo $this->fetch('content');

在内容部分。有人能解释一下吗?谢谢。

获取
将获取数据并在那里渲染

 echo $this->fetch('meta');
将获取您在页面中定义的元数据

    echo $this->Html->meta(
        'keywords',
        'enter any meta keyword here'
    );
    // Output
    <meta name="keywords" content="enter any meta keyword here" />

    echo $this->Html->meta(
        'description',
        'enter any meta description here'
    );
    // Output
    <meta name="description" content="enter any meta description here" />`
echo$this->Html->meta(
“关键词”,
'在此处输入任何元关键字'
);
//输出
echo$this->Html->meta(
“说明”,
'在此处输入任何元描述'
);
//输出
`
echo$this->fetch('content')

将呈现视图文件中定义的内容