我正在使用一个苗条的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();