CodeIgniter helper in the view

CodeIgniter's user guide explains that helpers can be loaded and their function used in views.

CodeIgniter does not load Helper Files by default, so the first step in using a Helper is to load it. Once loaded, it becomes globally available in your controller and views.

However it is not best pratice to load a helper in a view, so you could either auto-load the relevant helper, or load it in your controller(s).

A helper can be loaded anywhere within your controller functions (or even within your View files, although that's not a good practice), as long as you load it before you use it. You can load your helpers in your controller constructor so that they become available automatically in any function, or you can load a helper in a specific function that needs it.

So, using helper functions in a view is fine, although it is encouraged that the helper is loaded in a controller, or auto-loaded.


get_instance()->load->helper('HELPER_NAME');

Just load the helper in your controller, then

$this->load->helper('MY_common_functions');
$template['content'] = $this->load->view('your_view');

In the view call your function name directly. In this case I called my convertor function

echo convertor($params);