When I have a class with a subclass , and calls a method within the subclass from the class, everything is working out ok. But if a call the same method twice in the same script a get a function redeclaration error, is there anyone who knows a workaround for this problem or should I do this another way? (new to oop )
class One {
var class2;
//constructor
function One() {
$this -> class2 = new Two;
}
function getTestVar() {
$retVal = $this -> class2 -> getVar();
}
}
class Two {
var tmpVar;
function getVar() {
function getData() {
$tmpVar = "test";
}
$data = getData();
return $data;
}
I´m not 100 % sure of the code above as I dont have it at this location I´m writing from , but you get the idea!
So if I call class One:s getTestVar method more then once in a script I get a redeclaration fault on function getData in the method getVar of Class Two..
Greatful for help
Andreas andreas.perjus@pbs.fi