开发者

How would I call a helper from a helper in Codeigniter?

开发者 https://www.devze.com 2022-12-14 03:01 出处:网络
I\'m writing some custom helpers in Codeigniter and I want to call some functions from other helper files like date, etc, in my helper. I keep getting \"call to undefined function\" errors. Ho开发者_S

I'm writing some custom helpers in Codeigniter and I want to call some functions from other helper files like date, etc, in my helper. I keep getting "call to undefined function" errors. Ho开发者_StackOverflow社区w can I reference other helper functions from my helper?

Thx

D


As you can see from the source link provided, calling $this in reference to the CodeIgniter object is only available within your controllers, models and views. However to take full use of CodeIgniter's native resources from outside those, you simply have to make an instance of it like this:

$instanceName =& get_instance();

Then, to access those resources, instead of using $this->, you'd be using $instanceName->.

Source


function first_function()
{
    $ci =& get_instance();
    $ci->load->helper('date');
    $mysql = '20061124092345';
    $unix = mysql_to_unix($mysql);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消