PHP use one central variables file inside functions
<p>In PHP, what is the right way forward for the following situation:</p>

<p>I have a 'central' vars.php which contains some parameters like MySQL hostname, user, pass, a $Test variable which indicates if the code is running in a test environment or not, and some other variables which I use throughout my site.</p>

<p>Then I have a functions.php which contains all the functions I could use throughout my site.</p>

<p>In some of these functions, I might need some the variables out of the vars.php file.</p>

<p>What is the right way to make the vars.php available to 'everywhere' in PHP?
Now I am doing it like this:</p>

<pre><code>vars.php:
   &lt;?php
   if(strstr($_SERVER['HTTP_HOST'],"localhost"))
   {
       $Test = true;
   }
   ?&gt;

functions.php:
   &lt;?php
   function DoSomething()
   {
      include "vars.php";
      if($Test)
      {
         $String = "Test is true!";
      }
         else
         {
            $String = "Test is false!";
         }
      return $String;
   }
   ?&gt;

index.php:
   &lt;?php
   include "vars.php";
   include "functions.php;
   $DoSomething = DoSomething();
   echo $DoSomething;
   ?&gt;
</code></pre>

<p>While this does work, I have to include the vars.php in each function I define, this doesn't seem like a 'nice' solution to me.
Isn't there a way to define the variables in vars.php directly in the global scope, and be able to use them inside functions directly without having to worry about including them?</p>

<p>Thanks!</p>
