I have this class:
class testclass{
function func1(){
return "hello";
}
function func2(){
echo func1();
}
}
When I am running
$test = new testclass();
$test->func2();
I get an error: Fatal error: Call to undefined function func1() with the line index of echo func1();
My question now is, how do I make the func2 recognize func1
Is this a problem with the scopes?
func1()refers to the global functionfunc1(). Not thefunc1()of the current class. To call thefunc1()in the current class you'd use$this->func1()(orself::func1()if it's a static method)