In my CakePHP application, I return JSON and exit for specific requests. An example of this would be an attempt to access the login API as a GET request:
header('Content-Type: application/json'); echo json_encode(array('message'=>'GET request not allowed!')); exit;
However, I need an echo prefix with the content type so that it is sent as JSON. Otherwise, my code at the other end interprets it to the other.
Any ideas on how to get around this? Or at least improve it.
Update: Cake version 2.3.0
source share