0

I created a class that includes some others files

require_once('APIUtils.php');

in different functions.

The question is:

Is it better to call require at the top of the class or to choice each one in each function?

Because I've like 20 require in 40 functions.

u_mulder
  • 54,101
  • 5
  • 48
  • 64
Pierre
  • 490
  • 1
  • 7
  • 26
  • 3
    if you have that many requires.. I'd wager a bet to say you need some restructuring ... – treyBake Jun 18 '19 at 12:38
  • 5
    Take a look at autoloading classes https://stackoverflow.com/questions/7651509/what-is-autoloading-how-do-you-use-spl-autoload-autoload-and-spl-autoload-re – Claudio Jun 18 '19 at 12:39
  • Perfect, thanks, it's exactly what I was looking for @claudio – Pierre Jun 18 '19 at 12:43
  • Possible duplicate of [What is Autoloading; How do you use spl\_autoload, \_\_autoload and spl\_autoload\_register?](https://stackoverflow.com/questions/7651509/what-is-autoloading-how-do-you-use-spl-autoload-autoload-and-spl-autoload-re) – Dharman Jun 18 '19 at 12:53

0 Answers0