PHP loading / including files only if class is used
Posted
by
MrMalayev
on Stack Overflow
See other posts from Stack Overflow
or by MrMalayev
Published on 2012-04-06T23:27:21Z
Indexed on
2012/04/06
23:28 UTC
Read the original article
Hit count: 136
php
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*/ }
© Stack Overflow or respective owner