Welcome Guest, Not a member yet? Register   Sign In
How to use this->index()?
#1

[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!
#2

[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-gui...llers.html




Theme © iAndrew 2016 - Forum software by © MyBB