JSON PHP
header('Content-Type: application/json');
echo json_encode($data);
Amused Addax
header('Content-Type: application/json');
echo json_encode($data);
//I heavily use this, because I don't know, if any headers already was send, so the @ suppress the error message "headers already send in line xxx..."
@header('Content-type: application/json');
die(json_encode(['data' => $data, 'error' => $error]));