Welcome Guest, Not a member yet? Register   Sign In
Accessing methods from more than one class
#1

Hi all,

Hope you can help guide me here:

I am building as app and have different controllers per object. One Controller I have is, let's say, Car, and then I have separate controllers for enginewheelschassisGPS. I know that for my car to access the wheels methods i can use:

PHP Code:
class Car extends Wheels 

But then how can my Car class also access the methods in the Engine, Chassis and GPS classes.
As I understand it, I can't extend to multiple classes. So do I just need to replicate the relevant Wheels methods in Car. It seems inefficient.
Thanks
Reply
#2

No, those types of files should be libraries. You create them without extending the main Controller, just an empty class. And you load it in your controller car.

PHP Code:
$wheels = new \App\Libraries\Wheels(); 
Reply
#3

@jreklund is correct you should be putting those methods in a libraries
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB