我正在使用一个瘦api,我已经重新安装了好几次这个项目,并重新创建了所有的东西。在index.php文件的第15行出现错误。这就是错误
Fatal error: Uncaught RuntimeException: Unexpected data in output buffer
Notice: Undefined variable: db in /var/www/html/slimquote/index.php on line 15
Fatal error: Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in /var/www/html/slimquote/vendor/slim/slim/Slim/App.php:625 Stack trace: #0 /var/www/html/slimquote/vendor/slim/slim/Slim/App.php(335): Slim\App->finalize(Object(Slim\Http\Response)) #1 /var/www/html/slimquote/index.php(22): Slim\App->run() #2 {main} thrown in /var/www/html/slimquote/vendor/slim/slim/Slim/App.php on line 625
我已经删除并搜索任何字符之前,打开标签我仍然得到这个错误。有人知道这是什么吗?。。我到处搜索,每个人都指向结束标记?>,但我一个也没有了。我还注释掉了任何行,包括数据库配置和任何实例化数据库的行。。。感谢任何帮助。
index.php文件
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require 'vendor/autoload.php';
//require 'dbHandlers/DBconnection.php';
//$conn = new DBconnection();
//$db = $conn->dbConnect();
$app = new \Slim\App;
$app->get('/', function (Request $request, Response $response, array $args) {
// $query = 'SELECT * FROM quotes_tb ORDER BY id';
// $sql = mysqli_query($db, $query);
$response->getBody()->write("Hello world");
return $response;
});
$app->run();