I have a hook configured to run after the final rendered page has been sent to the browser.
$hook['post_system'] = array(
'filepath' => 'hooks',
'filename' => 'notes_hooks.php',
'class' => 'Notes_hooks',
'function' => 'write_notes',
);
With my notes hooks class being -
class Notes_hooks extends CI_Hooks {
function __construct()
{
parent::__construct();
$this->CI = get_instance();
}
function write_notes()
{
if(isset($this->CI->notes_model))
{
$this->CI->notes_model->batch_insert();
}
}
}
This all runs fine and runs the function it is supposed to do, apart from that it does the function before output has been sent to the browser. For example if I add a sleep after
$this->CI->notes_model->batch_insert();
Then when I load the page it sleeps then outputs, rather than the expected rendering and output of the page to the browser with PHP sleeping in the background.
I must be missing something?