Possible Duplicate:
[PHP] global in functions
Is it bad programming (PHP) practice to access a global variable in a function inside a class in following way?
class test{
function a(){
global $myvar;
..
}
function b(){
global $myvar;
..
}
}
Thanks.
It is not elegant. You should pass that var inside the constructor and save it into a
private $varinside the class to be used in every function with an easy$this->var.