0

I am using codeigniter bonfire framework for creating a web. Everywhere where i m using echo json encode i am getting error in error logs like :-

ERROR - 2015-07-06 17:38:49 --> Severity: Warning  --> Cannot modify header information - headers already sent by (output started at... )

Why this error generate in error logs file. Its a example code where the warning generating.

public function get_filter()
    {
        if(!empty($_GET))
        {
            $search = $_GET;
            $restaurant = $this->discount_model->get_offer_restaurant_by_discount($_GET);
            echo json_encode($restaurant);
        }
        else{
            $restaurant = $this->discount_model->get_all_discount_restaurants();
            echo json_encode($restaurant);
        }
    }

Here the error generated at echo json_encode($restaurant) line. How to stopped this error.

Gitesh Purbia
  • 1,094
  • 1
  • 12
  • 26

1 Answers1

1

There may be whitespace before the php open tag <?php in Your_Controller.php

Please remove whitespaces before <?php tags in all files.

  • If white space, error would point on line 1. Check [this](http://stackoverflow.com/questions/14769209/codeigniter-cannot-modify-header-information-headers-already-sent-by#answer-22818019) answer though. – Tpojka Jul 06 '15 at 18:19