What is the scope of require_once in PHP?
- by TMG
Simple question: Is the scope of require_once global?
For example:
<?PHP
require_once('baz.php');
// do some stuff
foo ($bar);
function foo($bar) {
require_once('baz.php');
// do different stuff
}
?>
When foo is called, does it re-parse baz.php? Or does it rely on the already required file from the main php file (analagous to calling require_once twice consecutively for the same include file)?
I saw this thread before, but it didn't quite answer the question:
http://stackoverflow.com/questions/1669707/should-require-once-some-file-php-appear-anywhere-but-the-top-of-the-file
Thanks for your help!