我得到了"致命的错误:使用包含的代码调用未定义的函数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;
}
}
Run Code Online (Sandbox Code Playgroud)
您必须指定上下文.与c ++不同的PHP并不this隐含.
$sectionContent = $this->getSContent($section);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
266 次 |
| 最近记录: |