2016-04-09 12 views
0

Ich versuche Slim auf meinem Windows 7-System laufen zu lassen. Bis jetzt habe ich alles mit Composer installiert, aber wenn ich ein sehr einfaches Programm ausführe, ist die Ausgabe nicht wie vorgesehen.Slim 3.3 fehlende Zeichen in der Ausgabe

Unten ist mein Code:

<?php 
ini_set('display_errors', 1); 
ini_set('display_startup_errors', 1); 
error_reporting(E_ALL); 

use Slim\App; 
use Slim\Http\Request; 
use Slim\Http\Response; 

require '../vendor/autoload.php'; 

$app = new App; 

$app->get('/', function (Request $in, Response $out, $args) { 
return $out->write("xxxxx"); 
}); 

$app->run(); 

Ich erwarte Ausgang "xxxxx", statt i "x" erhalten.

Das bedeutet, dass ich 4 Zeichen irgendwo verliere. Lauf PHP 5.5.12 Die Kodierung ist UTF-8 (nicht BOM)

Wenn ich laufen "curl -v http://localhost:8080/"

ich

D:\wamp\www\slim_test\src\public>curl -v http://localhost:8080/ 
* Trying 127.0.0.1... 
* Connected to localhost (127.0.0.1) port 8080 (#0) 
> GET/HTTP/1.1 
> Host: localhost:8080 
> User-Agent: curl/7.46.0 
> Accept: */* 
> 
< HTTP/1.1 200 OK 
< Host: localhost:8080 
< Connection: close 
< X-Powered-By: PHP/5.5.12 
< Content-Type: text/html; charset=UTF-8 
< Content-Length: 5 
< 

x* Closing connection 0 

ich Ihre Hilfe schätzen würde .

BEARBEITEN Sobald ich diese Zeilen an das Ende der Datei anhängen, ist die Antwort korrekt.

$response = $app->run(true); //Silent mode, wont send the response 
$response = $response->withoutHeader("Content-Length"); //Remove the Content-Length 

$app->respond($response); //Now we send the response 

Ich kann nicht herausfinden, warum .....?

Antwort

1

Dieses Problem wurde gelöst, als ich einen sehr dummen Fehler fand.

Ich hatte 2 Leerzeichen vor dem <?php Tag.