Slim Framework将<?php添加到json响应中

Working with Angular and Slim framework on an app. After a folder structure refactoring it appears that Slim is adding two <?php tags before the response body. Does anybody know what might be the reason? index.tmpl is plain html.

Sample code:

$app = new \Slim\Slim();
$view = $app->view();
$view->setTemplatesDirectory('./slimtmpl');
$app->get('/', function() use ($app){
 $app->render('index.tmpl');
});

$app->get('/sample', 'sample');

function sample(){
 $app = \Slim\Slim::getInstance();
 $response = $app->response();
 $response->write(json_encode($dummydata), 200);
}

And this is the response I get:

<?php<?php{"id":"1","dummy1":"asf","dummy2":"sdfsfsdf"}

1个回答



找到了罪魁祸首:在bootstrap.php中添加了两个空的php文件</ p>
</ div >

展开原文

原文

Found the culprit(s): two empty php files were added and required in bootstrap.php

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐