Skip to content

CodeIgniter Examples

nuketro0p3r edited this page Oct 20, 2014 · 3 revisions

Using CodeIgniter Helper Classes:

anchor()

To create a link using the anchor() function in one of your view files you would do this:

Where "Edit Profile" is the name of the link, and "profile/edit" is the URI to the controller/function you wish to link to.

site_url()

echo site_url("news/local/123"); The above example would return something like: http://example.com/index.php/news/local/123

base_url()

echo base_url("blog/post/123"); The above example would return something like: http://example.com/blog/post/123

This is useful because unlike site_url(), you can supply a string to a file, such as an image or stylesheet. For example:

echo base_url("images/icons/edit.png"); This would give you something like: http://example.com/images/icons/edit.png

(Optional) For more helpers, see:

https://ellislab.com/codeigniter/user-guide/general/helpers.html

https://ellislab.com/codeigniter/user-guide/helpers/url_helper.html

https://ellislab.com/codeigniter/user-guide/helpers/html_helper.html

https://ellislab.com/codeigniter/user-guide/helpers/form_helper.html

Clone this wiki locally