我想弄清楚如何在自己的類中使用方法。例如:PHP:我如何在自己的類中訪問/使用方法?
class demoClass
{
function demoFunction1()
{
//function code here
}
function demoFunction2()
{
//call previously declared method
demoFunction1();
}
}
,我發現是工作的唯一方法是,當我創建的方法中的類的新intsnace,然後調用它。例如:
class demoClass
{
function demoFunction1()
{
//function code here
}
function demoFunction2()
{
$thisClassInstance = new demoClass();
//call previously declared method
$thisClassInstance->demoFunction1();
}
}
但這不覺得正確......或者是這樣嗎? 有幫助嗎?
感謝