In the above example the method name is index(). The “index??? method is always loaded by default if the second segment of the URI is empty. Another way to show your “Hello World??? message would be this:

example.com/index.php/blog/index/

The second segment of the URI determines which method in the controller gets called.

Let’s try it. Add a new method to your controller:

<?php
class Blog extends CI_Controller {

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

        public function comments()
        {
                echo 'Look at this!';
        }
}

Now load the following URL to see the comment method:

example.com/index.php/blog/comments/