Assuming PHP version >= 5.2, which is a better solution for managing includes:
require_once DEFPATH . 'config.inc.php';
or
if (!defined('FOOBAR')) require DEFPATH . 'config.inc.php';
or something entirely different?
Site does not use a front controller or autoloader. Typical number of files needed to be included is 3 - 8.
I've heard, here and elsewhere, that require_once
adds overhead and does not play nice with caching. But I've also heard that a small number of require_once
statements is OK in practice in later versions of PHP.
There must also be some overhead associated with checking if something is defined, but that may be less of an issue.
In general, which is the better practice and why?
THANKS