O'Reilly logo

Programming with CodeIgniter MVC by Yehuda Zadik, Eli Orr

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example 1 – using built-in helpers

In this example, we will see how to use CI build-in helpers. For this example, we will use the URL helper for generating links. The URL helper file contains functions that assist in working with URLs. We will use the URL helper function site_url(), which returns the site URL as specified in the config file.

This example will be constructed from either of the following controllers:

  • application/controllers/ helperexample1.php

    This controller loads the built-in CI helper URL.

    $this->load->helper('url'); 
    

    The controller renders a view named helper-example1-view

  • application/views/helper-example1-view.php

    This view will use the URL helper to generate links in the view file

    Let us assume the URLs to the project root are as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required