CodeIgniter Forums
I have my own Function file. How can i use that? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: I have my own Function file. How can i use that? (/thread-24162.html)



I have my own Function file. How can i use that? - El Forum - 11-02-2009

[eluser]web_developer[/eluser]
Hello,

I have my own function file, I would like to use in Model, View and Controller (anywhere)
How can I use that functions? (I have put that function file in library directory)

But now how can I access my functions in Model, Controller and in View?


I have my own Function file. How can i use that? - El Forum - 11-02-2009

[eluser]saidai jagan[/eluser]
simply load that library and use it
$this->load->library('your_library');
$this->your_library->your_function();


I have my own Function file. How can i use that? - El Forum - 11-02-2009

[eluser]imn.codeartist[/eluser]
Better create a helper file using _helper suffix and place it in the helper folder

which is system/application/yourfile_helper.php


I have my own Function file. How can i use that? - El Forum - 11-02-2009

[eluser]CroNiX[/eluser]
Yes if its straight functions load as a helper as dixcoder suggests. If its a class load it as a library.


I have my own Function file. How can i use that? - El Forum - 11-02-2009

[eluser]mjsilva[/eluser]
Imaging that your file is called my_functions.php

1) place it in application/helpers rename it my_functions_helper.php
2) go to autoload.php under application/config, and auto-load it by adding your helper name to $autoload['helper'] array.
Code:
$autoload['helper'] = ('my_functions_helper');

And that's it, after doing this you can call your function everywhere.


I have my own Function file. How can i use that? - El Forum - 11-03-2009

[eluser]kakawett[/eluser]
That helped me too, thanks