Anything if you use directly in the Codeigniter framework directly, like base_url()
, uri_string()
, or word_limiter()
, All of these are coming from some sort of Helper
function of framework.
While some of Helpers
may be available globally to use just like log_message()
which are extremely useful everywhere, rest of the Helpers are optional and use case varies application to application. base_url()
is a function defined in url
helper of the Framework.
You can learn more about helper in Codeigniter user guide's helper section.
You can use base_url()
function once your current class have access to it, for which you needs to load it first.
$this->load->helper('url')
You can use this line anywhere in the application before using the base_url()
function.
If you need to use it frequently, I will suggest adding this function in config/autoload.php
in the autoload helpers
section.
Also, make sure you have well defined base_url
value in your config/config.php
file.
This will be the first configuration you will see,
$config['base_url'] = 'http://yourdomain.com/';
You can check quickly by
echo base_url();
Reference: https://codeigniter.com/user_guide/helpers/url_helper.html