For some reason when I call $this->load->model('whatever') in my controller, the page renders the source code for that model.
This is my controller:
<?php
class Testing extends CI_Controller {
function index()
{
$this->load->model('Testing');
$this->load->view('testing/view');
}
}
?>
If I leave out the model loading and load the view as normal, it works fine, but when i load the model the view is not rendered and the model source is.
Also, I tried adding a hook by putting
$hook['pre_controller'] = array(
'class' => 'Loader',
'function' => 'template',
'filename' => 'ViewTemplate.php',
'filepath' => 'hooks'
);
in my hooks.php and then
Class Loader{
function template($viewName, $data) {
$this->view('header');
$this->view($viewName, $data);
$this->view('footer');
}
}
in the "hooks/ViewTemplate.php" file. The goal is to use the template function in controllers instead of view, which will automatically insert a header and footer. Hooks are enabled in config.php. Whenever I add that section to hooks.php, the only output i'm getting when I load a view is the hook source.
Did I try to implement this wrong? Could I have messed up some CI setting? Could it be related to apache or php?
I'm not so worried about whether my hook works, but why I keep getting the source code for files rendered on my page.
<?phpopening tag at the top of your files. Someone else had the same problem earlier today.