CodeIgniter Forums
How to use this->index()? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to use this->index()? (/showthread.php?tid=58460)



How to use this->index()? - El Forum - 06-13-2013

[eluser][email protected][/eluser]
I was watching a tutorial saying this function of
this->index() will redirect the controller load to the index page...

But my question, who's index page that is ?
The main site's? or the controller's?

Does it even work? I tried it on my test side, get 404.

Thanks!


How to use this->index()? - El Forum - 06-13-2013

[eluser]Syllean[/eluser]
Code:
<?php
class Blog extends CI_Controller {

public function index()
{
  echo 'Hello World!';
}

public function rtm()
{
  $this->index();
}
}
?>

Quote:In the above example the function name is index(). The "index" function is always loaded by default if the second segment of the URI is empty.

$this->index() will run the index function and as a result echo Hello World!

RTM: http://ellislab.com/codeigniter/user-guide/general/controllers.html