I’m extending URL helper (MY_url_helper). How do I access base_url() within my helper function? I’m actually overriding base_url(), so I need to call the original base_url.
Edit 1:
This doesn’t work:
$CI =& get_instance();
$CI->load->helper('url');
$base_url = $CI->base_url();
Unfortunately built-in helper functions are defined in the global php namespace, once you define a function with a name
base_urlyou won’t be able to define another one with the same name, so you can’t load the originalbase_urlfunction from the original helper “somwehere else” and use it.For this reason CI’s built-in helper files define function in if blocks like this:
so even if you load the original helper file in your overridden version it doesn’t create a fatal error, but also doesn’t do anything meaningful.
In your concrete case, the base_url’s implementation is basically a:
you can lift it into your overridden version of
base_url.