Making the variables in @include("variables.php") global

My php script looks something like this. Is there someway to make the variables in variables.php global so that I don’t have to read the file with every function?


<?php
@include("variables.php");
// use variables from variables.php

Function_1();
Function_2();
Function_3();

function Funtion_1() {
@include("variables.php");
// use variables from variables.php
}

function Funtion_2() {
@include("variables.php");
// use variables from variables.php
}

function Funtion_3() {
@include("variables.php");
// use variables from variables.php
}

Have you tried:

global $var1;

Have you tried sending the variables to be used in the function call?

function Funtion_3(var1, var2, ...)

And why do you use a @ in front of the include? Do you expect an error? Shouldn’t the include file be there?

And if variables.php have 100 variables? The @ is out of habbit.

And if variables.php have 100 variables?

And all the functions need 100 variables? Wow, what kind of functions are they?

A solution might be create to create a class? At least you’d have to load the variables just once.