Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP class extending another class outside of folder

I have a general class which i like to have it extended by other classes.

I have my directory set up with folders and class files inside of those folders for example

Classes/users/users.class.php classes/general/general.class.php

I have the users class extending the general class but since they are in different folders I guess the general class is not found.

class users extends general {

}

Can someone please help me out figuring this out.

I should also mention i am using autload function

like image 571
Yeak Avatar asked Feb 11 '26 13:02

Yeak


1 Answers

When you have no autoloader then include the class before.

Then the class is known and you can use it.

require_once(__DIR__.'/../general/general.class.php');
like image 84
René Höhle Avatar answered Feb 13 '26 10:02

René Höhle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!