PHP cant use variable defined outside functions
Im working on a project (simple xml CMS) just to learn some basic PHP.

first i include a config.php file which contains information about the CMS, 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).

The structure looks like this:
    <?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){
    	}
    ?>

In config.php file i also use this code:
    
	$xml = simplexml_load_file('products.xml') or die('The Product xml file couldnt be loaded.');

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 got the same result).

Can someone please tell me my mistake? I know its simple, i just cant see clearly right now.

Thanks in advance.
PHP cant use variable defined outside functions
===

Im working on a project (simple xml CMS) just to learn some basic PHP.

first i include a config.php file which contains information about the CMS, 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).

The structure looks like this:
    <?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){
    	}
    ?>

In config.php file i also use this code:
    
	$xml = simplexml_load_file('products.xml') or die('The Product xml file couldnt be loaded.');

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 got the same result).

Can someone please tell me my mistake? I know its simple, i just cant see clearly right now.

Thanks in advance.