How to do require_once from multiple locations in one line?

Asked

Viewed 105 times

3

For example, I’m doing so:

require_once 'Testeum.php';
require_once 'Testedois.php';
require_once 'Testetres.php';

Can I do this with a single require_once? With attribute I can put comma:

private $testeum, $testedois, $testetres;

Has how to do with include, require, etc...?

  • after reading some PHP documentation, I believe it is not possible to do exactly what you want.

1 answer

3


It’s not possible to have a require/include in the class body this generates syntax error. It is also not possible to add an access modifier (public, protected and private) outside a class. The only place where it is possible is within methods.

  • Hi, hi, good morning! I know, what I wanted to know was, if so, if you had like me, instead of giving a lot of require_once, I use one, and be able to include a lot of paths in my program. Note: Other than __atoload

  • @Lucascarvalho the closest you can do is to create a configuration file (config.php or includes.php) on it (in the first version) call all the files you need in the other files just call the config.php/includes.php. If you want you can increment it past the files you want to include.

  • Got it, liked the solution! Thanks, rray!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.