Can a function in a class be called from another function? I create a
class object and call a method which calls another method in the same
class and I get erors.
class Nice
{
function getHi()
{
$greet = sayHi();
return $greet;
}
function sayHi()
{
return "Hi there from db.";
}
}
$greeting = new Nice()
$test = $greeting->getHi();
echo $test;
Fatal error: Call to undefined function: sayhi()
And yes I tried ->
$greet = this->sayHi(); too.
Why woun't this work? Or is this beyond the abilities of the PHP
scripting language?
Thanks for your help?
class object and call a method which calls another method in the same
class and I get erors.
class Nice
{
function getHi()
{
$greet = sayHi();
return $greet;
}
function sayHi()
{
return "Hi there from db.";
}
}
$greeting = new Nice()
$test = $greeting->getHi();
echo $test;
Fatal error: Call to undefined function: sayhi()
And yes I tried ->
$greet = this->sayHi(); too.
Why woun't this work? Or is this beyond the abilities of the PHP
scripting language?
Thanks for your help?
Comment