CodeIgniter Forums
Class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Class (/showthread.php?tid=71651)



Class - frankenestain - 09-10-2018

How to load another class method from a different class?
Thanks


RE: Class - neuron - 09-10-2018

(09-10-2018, 01:26 AM)frankenestain Wrote: How to load another class method from a different class?
Thanks
what do you mean with class?
library, controller, model?


RE: Class - ragingTorch - 09-10-2018

Perhaps this?
https://www.codeigniter.com/user_guide/general/creating_libraries.html#utilizing-codeigniter-resources-within-your-library

It's not limited to just CI resources, you can call your own libraries and methods using the same instance.


RE: Class - ignitedcms - 09-10-2018

I'm not sure, but if you have logic that you wish to use across different controllers, perhaps you should put that inside a model. That way you can access that logic from any controller.


RE: Class - Wouter60 - 09-10-2018

Let's say you have a library called Assets.php (in the application/libraries folder), and this class has a method called create_header() which returns a string.

In your controller:
PHP Code:
$this->load->library('assets');
$hdr $this->assets->create_header(); 

Is this the information you were looking for?