I was reading how having globals inside a method was not good.
Something like this.
class one{
function one(){
return "Returned one";
}
}
$ones = new one;
class two{
public $one;
function two(){
$this->tree();
}
function tree(){
global $ones;
echo $ones->one();
}
}
$callme = new two;
That worked well but is not a good way to go.
Now, I did something like this.
class one{
function one(){
return "returned one";
}
}
class two{
public $one;
function two(){
$this->one = new one;
$this->tree();
}
function tree(){
echo $this->one->one();
}
}
$callme = new two;
Hey! Who knew that $this->class->method(); would work. (Well maybe most of you but I didn't.)
Anyway, is this is a good/standard practice though?