Adding sub controllers in Codeigniter

In Codeigniter the index() method is always loaded by default if the second segment of the URI is empty. Like this :
Other than this if we want to load a another method from the same URL then we may add other methods as sub controllers.

Example (Hello.php)

class Hello extends CI_Controller {
	public function index()
		echo "Hello World!";

	public function anotherMethod()
		echo "Hello another method";


URL : http://localhost/myApp/index.php/Hello/anotherMethod
Output : Hello another method


You may also like...