Reputation: 1144
I created the file MY_Router.php
inside the core directory with this code:
<?php
class MY_Router extends CI_Router {
function MY_Router()
{
parent::CI_Router();
}
function _validate_request($segments)
{
// Comprueba que el controlador no existe
if (!file_exists(APPPATH.'controllers/'.$segments[0].EXT))
{
$segments = array("page", "load", $segments[0]);
}
return parent::_validate_request($segments);
}
}
?>
When I call the application, this error appears:
Fatal error: Call to undefined method CI_Router::CI_Router() in /home/david/public_html/CodeIgniter_2.1.0/application/core/MY_Router.php on line 6
Where is the problem?
Upvotes: 1
Views: 2943
Reputation: 3765
The problem is that there is no method in the CI_Router class called CI_Router()
. In PHP4, constructors have the same name as the class. In PHP5, constructors are named __construct()
.
To fix the issue, change the constructor in the MY_Router class from
function MY_Router()
{
parent::CI_Router();
}
to
function __construct()
{
parent::__construct();
}
Upvotes: 6