作者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/m.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