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 follows:
http://mydomain.com/myproject
.http://mydomain.com/myproject/helperexample1