我得到「致命錯誤:調用未定義的函數getSContent()」與包含的代碼,但是......你可以看到:我的功能就在那裏!爲什麼我會收到「缺少功能」錯誤?我的功能就在那裏!
請幫忙。我相信我需要一些睡眠。
class InfoController extends AppController {
var $name = 'Info';
var $helpers = array('Html', 'Session');
var $uses = array();
function display() {
$path = func_get_args();
$section = $path[0];
$mainMenuActiveElement = $section;
$sectionContent = getSContent($section);
$this->set(compact('section', 'mainMenuActiveElement', 'sectionContent'));
$this->render('/pages/info');
}
function getSContent($section) {
$sectionContent = '';
switch ($section) {
case 'bases':
$sectionContent = 'some content';
break;
case 'informacion':
$sectionContent = 'some other content';
break;
}
return $sectionContent;
}
}
哦!我真的需要去睡覺。謝謝@VolkerK! – vmarquez 2010-08-07 21:18:38
我真的很抱歉,「不會假設......隱含」部分;-)請參閱http://en.wikipedia.org/wiki/Name_resolution – VolkerK 2010-08-07 21:22:34
它在PHP中沒有任何意義。參見http://stackoverflow.com/questions/3345408/what-is-the-point-of-having-this-and-self-in-php/3376490#3376490 – Artefacto 2010-08-07 21:28:08