PHP loading / including files only if class is used
- by MrMalayev
I have a couple of classes, and certain classes require only a part of an SDK.
For example
class a {
/* requires filea.php*/
}
class b { /*requires fileb.php*/ }
Instead of including the files at the top like
require_once 'filea.php';
require_once 'fileb.php';
class a { /*do stuff*/ }
class b { /*do stuff*/ }
Can I just include them in the class, so one only loads when an object is made?
class a { require filea.php; /*do stuff*/ }
class b { require fileb.php; /*do stuff*/ }