作者BF109Pilot (德军王牌飞行员)
看板PHP
标题[请益] Model的设定会被显示出来
时间Tue Jul 1 11:48:07 2014
小弟架了cakephp-2.5.2
要用来作简单网页用途
但遇到个问题
我有支API是捞DB资料然後吐JSON出来
但是JSON前老是会多一段code
而那段code正好是我所use的model档
如:
App::uses('AppModel', 'Model'); class Creature extends AppModel { (下略)
我试过
Configure::write('debug', 0);
以及
$this->layout = false;
$this->layout = 'ajax';
$this->autoRender = false;
都不能把那段消掉
不知道有没有前辈能帮我解惑一下
愿付1000P聊表心意(不限一位)
感谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 111.249.183.76
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/PHP/M.1404186490.A.B55.html
1F:→ up9cloud:偏门解:把吐出之前的code夹在ob_start()ob_clean()间XD~ 07/01 23:00
不知道跟Model档有没有关系
官方Model档范例是
App::uses('AppModel', 'Model');
class Ingredient extends AppModel {
public $name = 'Ingredient';
}
我照复制存成.php是可以跑
不过这model档的内容都会被显示出来
而且没用php标签包起来感觉怪怪的
但我在最前面加个<?php
就又变成Missing Database Connection
很古怪
※ 编辑: BF109Pilot (111.249.183.76), 07/02/2014 00:52:53
2F:推 Peruheru:我用的是ZF,不过我看官网范例也是没特别写出<?php ?> 07/02 08:41
3F:→ Peruheru:但我还是有用php标签头尾包起来,而且可以跑,我觉得你要 07/02 08:42
4F:→ Peruheru:当作官网把这个当作基础中的基础所以没写出来而已 07/02 08:42
5F:→ Peruheru:变成要研究包起来以後要怎麽解决那个问题 07/02 08:43
6F:→ olctw:前面一定要有 <?php 吧,也顺便检查一下你的资料库设定 07/02 13:35
7F:→ BF109Pilot:哈哈哈谢谢三位 用一楼方法暂时解决 但还是都给谢礼 07/03 21:54