Hello friends,
I am having a set of global variables defined in my libraray file. This library file contains one function where all the variables are set.
Here is my function defined in library.
function setErrorData()
{
global $var1;
global $var2;
global $var3;
if(some condition matches)
{
$var1 = "value1";
$var2 = "value2";
$var3 = "value3";
}
else
{
$var1 = "value3";
$var2 = "value4";
$var3 = "value5";
}
}
Now I am calling this library function in my class file which in turn uses this global variables. Now in that class files I have around 10 functions that uses these global variables for setting error data. And I have to explicitly define all these global variables repetitively inside function.
Here is my class along with functions.
class XYZ
{
function XYZ()
{
....
}
function A()
{
global $var1;
global $var2;
global $var3;
.
.
.
.
}
function B()
{
global $var1;
global $var2;
global $var3;
.
.
.
.
}
function C()
{
global $var1;
global $var2;
global $var3;
.
.
.
.
}
.
.
.
.
}
Now, what I want is to avoid declaring these variables all the time in the class functions. Is it possible to do this? If yes then how? Please help me. Thanks in advance.