3
votes

I'm using CI 3.1.10.In the index.php file i use development enviroment.

MY controller

<?php
class Test extends CI_Controller {
public function index(){
    echo CI_VERSION; 
 }
}

?>

When i try to access the test class then it show me this error

This is the image that show me the warning.

Screenshot of the error is attached

8
Try to add ob_start(); on the first line of index.php in root directory, hope it will help.ashokan
Using PHP and SSI at the same time also leads to this problemAlex

8 Answers

5
votes

ob_start();

on the first line of index.php in root directory. This works.

1
votes

Open the config.php and add ob_start(); it will help to delay the sending of the HTTP header

Look at the example below

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
ob_start();
1
votes

For me the error occured because i accidentally added some empty lines after php closing bracket ?> in a helper class i loaded before loading the session library.

1
votes

For further understanding why this happens, php is supposed to set headers before it can send the response body to either browser or console.

Usual suspects are print_r, print, echo or whitespaces before modifying headers using methods like header, session_start, set_cookie etc.

This is answered nicely here as well How to fix "Headers already sent" error in PHP

0
votes

Remove Close tag from the Controller ?> then check

0
votes

About codeignitor. It is about case sensitivity. My file name was Header.php after changing it to header.php. it worked for me.

0
votes

In my case using delight/auth I had the same error when calling my login.php.

The problem was that the require 'vendor/autoload.php'; was NOT the FIRST statement in the file.

Put it first and all worked fine. In ALL my .php that use this service <? php require 'vendor/autoload.php'; include ('root.php'); include($root."db_settings.php"); require_once 'errormsg.php';

Good luck

0
votes

on index.php file at the top paste this

ob_start(); 

this works for me