Controllers are the components of your web application. They are classes that can be loaded by the user, selecting them by URI. For example yoursite.com/index.php/news/list/date/ will load the news controller, execute the list method and pass the parameter date.
By default the way to select a controller is the following:
yoursite.com/index.php/class/method/params/
If class or method are not passed, the Loader will load the default controller (class) and default action (method).
Create your first controller
Create a controller, is pretty easy, this is how it looks:
function index(){
echo 'this is a controller';
}
function another_action( $params ){
echo 'you just said: ' . $params[0];
}
}
save your file into application/controllers directory as News.php, now just call your controller with the uri index.php/news/another_action/cool/.
Is it clear? Give a look to the code to better understand how it works.
