0

This is not like other question. I tried all other way. but still not working. It works locally, but error occurs when uploaded live.

<?php
header('content-type: application/json');
include('lib/functions.php');



if($_SERVER['REQUEST_METHOD']=="GET")
{
    $json = get_localtion_list();
    echo json_encode($json);  
}

What I tried:
ob_start() and ob_end_flush();
Then
changed header like this:

header('content-type: application/json;charset=utf-8');

I think the error happens only on php 7

I placed header first. But that doesn't work

Warning: Cannot modify header information - headers already sent by.../index.php on line 2

Rupesh
  • 91
  • 2
  • 9

1 Answers1

0

Probably your 'lib/functions.php' file throws an error header which are sent first before your: header('content-type: application/json'); .

Try to switch places if possible: header('content-type: application/json'); include('lib/functions.php');

The best way is to fix the error which is occurring

EdvinasPocius
  • 173
  • 2
  • 10