這可能是一個非常簡單的問題,但Google今天不是我的朋友。使用同一類別的功能
我有這樣的事情,但它說調用未定義功能
<?php
class myClass{
function doSomething($str){
//Something is done here
}
function doAnother($str){
return doSomething($str);
}
}
>
這可能是一個非常簡單的問題,但Google今天不是我的朋友。使用同一類別的功能
我有這樣的事情,但它說調用未定義功能
<?php
class myClass{
function doSomething($str){
//Something is done here
}
function doAnother($str){
return doSomething($str);
}
}
>
請嘗試以下操作:
return $this->doSomething($str);
嘗試:
return $this->doSomething(str);
你可以嘗試一個靜態調用是這樣的:
function doAnother ($str) {
return self::doSomething($str);
}
或者,如果你想成爲一個動態調用,您可以用$ this關鍵字,從而調用一個類實例的功能 :
function doAnother ($str) {
return $this->doSomething($str);
}
當然。對不起,這是早期:( – 2009-12-21 08:38:02