Sunday 22 December 2019

php - Why does Code Igniter give me a white page?




Hey, not sure why CodeIgniter is giving me a blank page when I load a simple model. I'm breaking the code down, backwards, and I can't figure out what's breaking. Here's the controller:



class Leads extends Controller {

function Leads() {
parent::Controller();
$this->load->scaffolding('leads');

}

function index() {
$data = array( 'title' => 'Lead Management' );

$this->load->view('html_head', $data);
$this->load->view('leads/home');
$this->load->view('html_foot');

}


function view() {
$this->load->model('Leads');
$this->load->view('html_head');
$this->load->view('leads/view');
$this->load->view('html_foot');
}

}



Here's the model:



class Leads extends Model {

function Leads() {
parent::Model();
}



}



The only way I don't get a white page on /view is if I comment out the loading of the model. I have absolutely no idea what I'm doing wrong, I'm copying the examples and structure literally right off the CI site.


Answer



Both your classes are named "Leads". When CI includes these, they are loaded into the same namespace. You probably have a "Cannot redeclare class 'Leads'" error. Try renaming the model and you should be fine.



Edit: guess confirmed


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...