I'm a beginning codeigniter user, and I cannot find well readable examples nowhere. Here's a simple code in a controller
namespace App\Controllers;
class Home extends BaseController {
public function index() {
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<note><to>Tove</to><from>Jani</from><heading>Reminder</heading></note>';
//$this->output->set_content_type('text/xml'); causes an error
header("Content-type: text/xml");
echo $xml;
exit; //works only with the "exit".
}
}
if I remove the "exit
" or write "return $xml
" after header(.., then the codeigniter removes somewhere the header ("Content-type: text/xml") and browser displays a plain text instead of correct xml-application.