I was wondering if you can overload functions in PHP, in particular in CodeIgniter. For example, in my controller, if I were to load the view, but it would be different from whether the variable was specified as a parameter or if it was left empty. This is a concept that I tried, so I learned in other languages:
<?php
function load_view(){
$this->load->view('view');
}
function load_view($var){
$this->load->model('data');
$data = $this->data->getInfo($var);
$this->load->view('view', $data);
}
?>
But when I tried this, I get the error "Fatal error: unable to override controller :: load_view" ...
Any help would be greatly appreciated. Thanks in advance!
source
share