fri*_*der 0 php function undefined scopes
I have this class:
class testclass{
function func1(){
return "hello";
}
function func2(){
echo func1();
}
}
Run Code Online (Sandbox Code Playgroud)
When I am running
$test = new testclass();
$test->func2();
Run Code Online (Sandbox Code Playgroud)
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?
function func2(){
echo func1();
}
Run Code Online (Sandbox Code Playgroud)
should be
function func2(){
echo $this->func1();
}
Run Code Online (Sandbox Code Playgroud)
http://www.php.net/manual/en/language.oop5.visibility.php
self:: vs className:: inside static className metods in PHP