How to Extend CodeIgniter Helper?

CodeIgniter Helper Function are available anywhere in the code, more than 20 CI Helpers are there(URL, Form, Directory, …etc). You can Easily Extend CodeIgniter Helpers. CodeIgniter Helper is just a PHP File with the bunch of functions, CI helper is not a class.

You can extend a CodeIgniter helper in a similar way to controllers and models. First, save a file called “MY_[name]_helper.php” to application/helpers where [name] is the name of the helper. To extend the URL helper it would be “MY_url_helper.php”. There is no need to extend any class here as helpers are just a bunch of functions. Just open PHP tags and start writing your functions to this file. Remember not to add a closing PHP tag as it may cause trouble with headers. It’s as simple as:

You load an extended helper the same way you load a normal helper. To load the url helper from a controller (which is the best practice) just use $this->load->helper(‘url’);. This makes your new functions available globally. Remember this means you access them directly (not with $this->url_helper->my_function()).

If you use this helper in a lot of locations you can have it load automatically by adding it to the autoload configuration file.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

18 Comments

  1. Dude I feel you should get in trouble for smoking weed!
    Obviously. The realest G ever. R.I.P. His Soul. everybody should smoke weed.
    Does Mitchel Musso smoke weed? How do you get higher if you smoke weed?

  2. I’m amazed, I must say. Seldom do I come across a blog that’s both equally educative and amusing, and without a doubt, you have hit the nail on the head.
    The issue is something that too few people
    are speaking intelligently about. I’m very happy that I came across this in my hunt
    for something concerning this.

  3. Excellent beat ! I wish to apprentice at the same time as you amend your web site, how
    could i subscribe for a weblog web site? The account aided me
    a applicable deal. I had been tiny bit familiar of this your broadcast offered vibrant clear idea

  4. Hi there there Very nice Blog you have in this article, it feels like you add a great deal of are employed in it.
    Im just looking into some Blog to get ideas for my Website.
    I offer you Bongs for Sale, plus a great Community on my small site.
    If you’re interested in Bongs available for purchase,
    or maybe a Bong Onlineshop, please check me out and leave me
    a submit.

    br, Moe

  5. Somebody necessarily help to make critically
    articles I might state. This is the very first time
    I frequented your web page and up to now? I amazed with the research you made
    to make this particular submit incredible. Fantastic task!

  6. I don’t even know how I ended up here, but I thought this post was good.

    I don’t know who you are but certainly you are going to a famous blogger if you aren’t
    already 😉 Cheers!

  7. Hi there Good Blog you might have in this article, it seems like you put lots of work in it.
    Internet marketing just checking out some Blog to acquire inspiration for my Web
    site. I offer Bongs for Sale, as well as a great Neighborhood on my site.
    Or perhaps a Bong Onlineshop, make sure you verify me out and leave us
    a publish, if you’re considering Bongs for Sale.

    br, Moe

Leave a Reply

Your email address will not be published.