• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing methods from more than one class

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.

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(); 

@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 )

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.