我开始使用 cakephp,但我仍然有一些疑问。正是关于 .ctp 文件。经过研究,我发现它们是用于 phpcake 读取 php 代码的模板文件。但是编码呢。我在一个带有“Utf-8 without bom”编码的文件中测试了这段代码,但浏览器仍然无法识别以下示例中包含的“ç”或“ã”之类的字母:
<!-- File: /app/View/Posts/add.ctp -->
<h1>Add Post</h1>
<?php
echo $this->Form->create('Post');
echo $this->Form->input('Nome Produto');
echo $this->Form->input('Código Produto');
echo $this->Form->input('Versão');
echo $this->Form->input('Data');
//echo $this->Form->input('body', array('rows' => '3'));
echo $this->Form->end('Criar Ficha');
?>
我需要将一些特定配置添加到此 ctp 文件中以避免此编码问题?
PS问题解决了。表单->输入创建错误。本来应该:
echo $this->Form->input('cod_produto', array('label' => 'Código Produto:'));
因为第一个参数是 bd 中字段的名称。感谢马克的所有帮助!