greetings
on my project I have a xml file that contains some values, that I must use on my site. For that I read and parse the XML. The problem is where I store the values that I read from XML (must I use Sessions?, must I use Static variables?, must I use Global variables?)
Imagine that my xml file contains the following data:
<?xml version="1.0"?>
<dbsettings>
<dbserver>
localhost
</dbserver>
<dbuser>
root
</dbuser>
<dbpassword>
root
</dbpassword>
<dbdatabase>
mydatabase
</dbdatabase>
</dbsettings>
fom my login.php script I read the XML file, parse it to retrieve the values to use them on the other files of the site.
I have a file named variables.php that contains my global vars like the site title, path to upload images, etc. In order to be able to use the vars defined on file variables.php I do (on each php file) a
require_once("variables.php")
so on login.php file I do the require_once of variables.php. And I want to store on variables defined on variables.php the values retrieved from the XML file, but when I do the require_once("variables.php") on another php file, for example the file savedataondatabase.php, the vars for database are no longer assigned 🙁( because I have the line of code
$dbServer=""; // this var should have and keep the value of XML once XML is readed and parsed
the question is (I belive): where can I store static data (following a OOP approach) that is loaded from XML (or another source) and stay unchanged when I require the file that the vars are define on, in order to use them on the other files of the site?
Or any better approach for this scenario is VERY welcome! If one have a betteridea to do this, please feel free to post it 🙂
Hope one help me on this one 🙁
TIA
Almeida