dongwo6477 2019-02-07 22:16
浏览 86

使用slim框架在index.php上找不到错误的来源

I'm working on a slim api using and I have reinstalled the project several times and recreated the everything. I'm getting error on line 15 of my index.php file. this is the error

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

I have removed and search for any character before the opening tag Still I keep getting this error. does anyone know what this is?.. I have search all over, and everyone points to closing tags ?>, but I have none left. I have also commented out any line including database configuration and anything instantiating a database... any help appreciated. index.php file

<?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();
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试