How to use helper function in codeigniter 4

Deepak Tailor Image
Deepak Tailor - Sep 22 2020
How to use helper function in codeigniter 4

Helpers are functions that help in your code. There are some helpers in codeigniter 4 like html helper, URL helper, from helper, text helper, cookie helper and many more. The work of all helpers is different. Such as linking css files in html helper work view file, creating URL helper work link, form helper's work building form.

We can also make helper custom. Who does his according work.

How to create custom helper

The custom helper we save is named filename_helper.php. Create this file in a folder containing helpers.

// helper expample


How to load helper in controller file

The helper can also be loaded anywhere in the controller. For example:

// load single helper in controller


// text helper example
echo word_limiter('my name is deepak tailor',4);
// output : my name is deepak...

// from helper example
echo form_open('home/submit_form');
echo form_close();

// url helper example
echo base_url();
// output : my name is deepak...

// load multiple helpers in controllers with array
Deepak Tailor Image
Deepak Tailor

My name is Deepak tailor as a fullstack developer. I have been in the IT industry (PHP, Nodejs, flutter) for the last 5 years. For professional and customize web development & app development, you can send inquiry on our email.
You can contact him at