[resolved]Output buffering

Hello every body i’ve a problem .
look here :

In theory i have this : {“result”:0,“test”:“super test”}
In reality i have this : {“result”:0,“test”:"s

In my local server if i turned of output_buffering off , the problem is resolved, but in production on a webserver where i don’t have acces to php.Ini i can’t turn off …

I try this

$api = new \Slim\App([‘settings’ => [‘outputBuffering’ => false]]);

But still not working… so what can i do ??


Can you show some code? Would help finding the problem.

Of course :
header(‘Access-Control-Allow-Origin: *’);
require ‘vendor/autoload.php’;
require ‘includes/token.php’;
require ‘includes/database.php’;
require ‘includes/methodes.php’;
//On genere une instance de slim.
$api = new \Slim\App([‘settings’ => [‘outputBuffering’ => false]]);
$cors = new \CorsSlim\CorsSlim();

for example my method getNewsFct

function GetNewsFct(Request $request,Response $reponse){

$retour = array("result"=>0);
$list = array();
$sql    = " SELECT  news_id,news_date,news_titlefr,news_titlenl,news_contentfr,news_contentnl
            FROM news
            ORDER BY news_date LIMIT 5,20";
try {
    $db = getDb();
    $req = $db->prepare($sql);
    foreach($result as $k=>$v){
        $list[] = array(    "new_id"    =>  $v['news_id'],
                            "date"      =>  $v['news_date'],
                            "titlefr"   =>  $v['news_titlefr'],
                            "text"      =>  $v['news_contentfr'],
    $retour = json_encode($list);
    $db = null;
} catch(PDOException $e) {
    $retour ='{"error":{"text":'. $e->getMessage() .'}}';
return $reponse;


I’ve write a method

function RenderFct($retour){
echo $retour;
$retour = ob_get_clean();
echo $retour;

With that, all it’s good, but is it a good pratice??

Same questions with CORS MiddleWare which not work and i write the header manually and that’s good… but again why ? and it’s a good pratice?

Thank for your help

Somewhere you have some blank spaces before an opening <?php tag.

Oki first problem is resolved , thank