SOLVED Caract added to body if i use $response

Hi everybody !
If i use slim response object my webserver return space+cr+lf before my real response.
Code with 3 char added :
$retour_json=new stdClass();
$retour_json->Message=“Welcome”;
$retour_json->API->$base_version;
retour_json->API->Serveur=_SERVER[‘SERVER_SOFTWARE’];
$retour_json->API->Name_Serveur=gethostname();
return $response->withStatus(200)
->withHeader(‘Content-Type’, ‘text/plain’)
->withJson($retour_json);

Code without 3 char added :

$retour_json=new stdClass();
$retour_json->Message="Bienvenue sur le webservice HH Informatique";
$retour_json->API->$base_version;
$retour_json->API->Serveur=$_SERVER['SERVER_SOFTWARE'];
$retour_json->API->Name_Serveur=gethostname();
return json_encode($retour_json);

Please Help me.

EDIT when i use stream all of my docs have 3 byte added :
20 0D 0A 4D 5A 90 00 03 00 00 00 04 00 00 00 FF
If i use an HEXA editor and remove this 3bytes the docs works.

Check your index.php file for invalid PHP tags.

Hello,
Thank you very much…
A double";" in one of the required file files …
a stupid, sorry mistake.

1 Like