I'm building a PHP application and I'm not quite sure how to store global configuration settings that can be truely accessed anywhere - it seems that content that is included cannot access other content included from the main, starting page. For example, if index.php includes foo.php and bar.php, bar.php don't have foo.php but index.php has both of them - the included files just can't refer to the other ones. Is this correct?
If yes, how would I set up something like this up?
index.php
<?php
include 'functions/load.php'
echo getHeader();
?>
functions/load.php:
<?php
include_once 'config.php'
include_once 'header.php'
//loads the includes
?>
functions/config.php:
<?php
//I want to store the site URL here.
$siteURL = "http://127.0.0.1";
?>
functions/header.php:
<?php
function getHeader(){
return "Header for " . $siteURL;
}
?>
How can I set up an config file that can be then accessed anywhere, including inside other included files? Also, is including a file that lists the other includes good practice?