我在笨2.1.0應用程序中有此錯誤控制器調用來自相同的方法相同的靜態方法:無法從同一個類
<?php
class Error extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
set_status_header(404);
$data->menuItems = Main::_menu();
$data->title = "404 error !";
$data->pageview = 'templates/404';
$this->load->view('templates/main', $data);
}
public function facebook()
{
set_status_header(404);
$data->menuItems = Main::_menu();
$data->title = "Facebook error !";
$data->pageview = "templates/facebook_error";
$this->load->view('templates/main', $data);
}
}
?>
的Maincontroller _menu:
<?php
class Main extends CI_Controller
{
// ... a lot of methods here ...
public static function _menu()
{
static $menuItems = array(//just a simple array
);
}
}
?>
的Facebook()方法與index()完全相同,但是索引工作正常,facebook()會拋出以下消息:
Fatal error: Class 'Main' not found in /var/www/MYApplicationName/application/controllers/error.php on line 22
地球怎麼可能?我怎樣才能從facebook()方法達到Main::_menu()
?
是否包含MainController文件?該錯誤意味着它無法找到該類,通常是因爲類文件未包含在腳本中。 – DavidS 2012-08-15 10:09:32
這是整個Error類。 index()方法中沒有額外的代碼。如果這兩者是相同的,但如果不能調用其他的可能性,那又如何呢?或者是index()方法是一個特殊的方法?是的,我知道如何包括一些東西,但我的問題是如何可能的索引()的作品? – kissgyorgy 2012-08-15 10:13:23
「Main」類在哪裏? – PeeHaa 2012-08-15 10:21:14