Using CodeIgniter 2.0.3 on XAMPP 1.7.7 I have code where I get the error as: Unable to load the requested file: home.php
The home.php
code as follows stored in ./ci2/application/controllers
:
class Home extends CI_Controller {
function Home()
{
parent::__construct();
}
function index()
{
$this->load->view('home');
}
While using it just notice:
controller's name is home.php
File named home.php must be present in ci/views
Incase file extention in view folder is not php eg like its html.
then load it using : $this->load->view('home.html');
the function u need to call from outside must be public So make it:
public function index() {... }
as u are calling the constructor for the class Home. Call it like:
class Home extends CI_Controller {
function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('home');
}
Now it will work !
Your call to $this->load->view('home');
will be looking for home.php
in /ci2/application/views/
. That's the file it can't find.
I'm assuming you're calling http://myapp/index.php/home/ - that means it'll automatically call the index()
method.
class Home extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->view('home');
}
}
Please check the name of the file you have created in application/views/, because otherwise the code is correct.