Welcome Guest, Not a member yet? Register   Sign In
Direct echo in Controller - bad parctice?
#8

(This post was last modified: 04-02-2015, 07:17 AM by kenji.)

or use output class 

http://www.codeigniter.com/userguide3/li...set_output

http://php.net/manual/fr/json.constants.php


PHP Code:
$response = array('status' => 'OK');

$this->output
        
->set_status_header(200)
 
       ->set_content_type('application/json''utf-8')
 
       ->set_output(json_encode($responseJSON_PRETTY_PRINT JSON_UNESCAPED_UNICODE JSON_UNESCAPED_SLASHES))
 
       ->_display();
exit; 


result : 
Code:
{
   "status": "OK"
}
Reply


Messages In This Thread
RE: Direct echo in Controller - bad parctice? - by kenji - 04-02-2015, 07:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB