title: PHP can't use variable defined outside functions
body: <p>I'm working on a project (simple XML CMS) just to learn some basic PHP.</p>
  
  <p>First I include a config.php file which contains information about the CMS, and then I include a route.php for the URL routing and after that I include a functions.php file which is pretty similar to the WordPress' one (contains all the functions to for example load posts, tags, categories, etc.).</p>
  
  <p>The structure looks like this:</p>
  
  <pre><code>&lt;?php
      function latestProducts($amount = 6){
      }
  
      function products($search = FALSE, $query= '', $page = 1, $results = 5){
      }
  
      function getProductById($id){
      }
  
      function getProductTitleById($id){
      }
  
      function getProductByExcerpt($excerpt){
      }
  
      function getProductTitleByExcerpt($excerpt){
      }
  
      function getPost($id, $title, $description, $category, $excerpt = FALSE){
      }
  
      function getTitle(){
      }
  
      function breadcrumb($params, $first){
      }
  
      function pagination($page, $pages){
      }
  ?&gt;
  </code></pre>
  
  <p>In config.php file I also use this code:</p>
  
  <pre><code>$xml = simplexml_load_file("products.xml") or die("The product XML file couldn't be loaded.");
  </code></pre>
  
  <p>But when I try to access $xml from within the functions I prepared in functions.php, I get a undefined variable notice. (I also tried placing the $xml variable inside the functions.php before the definition of the functions, but I got the same result.)</p>
  
  <p>What is my mistake? I know it's simple; I just can't see clearly right now.</p>