I have a PHP file called config.inc.php which read an XML-format configuration file into a varible - $config - using SimpleXML. I 'require' on every other page that needs access to the configuration file. However, I find that I am having problems with this.
If I do:
require 'config.inc.php';
class Test
{
public function UseConfig()
{
var_dump($config);
}
}
Then I find that $config is not accessible. If I put another require inside the UseConfig function then all works well, but for some reason it won't work as above. This wouldn't be a problem, except that I don't want to have to continually reread the configuration file everytime I want to access it.
Is this PHP getting rid of the SimpleXML object prematurely, or is there something amiss with my PHP knowledge? Please let me know! :p
Thanks