2010-09-02 135 views
3

致命错误:类“控制”在<local_path>\system\application\controllers\welcome.php没有发现3号线笨,PHP5,致命错误:类“控制”未找到

<?php 

class Welcome extends Controller { 

    function __construct() 
    { 
     parent::Controller(); 
    } 

    function index() 
    { 
     $this->load->view('welcome_message'); 
    } 
} 

/* End of file welcome.php */ 
/* Location: ./system/application/controllers/welcome.php */ 

我初学PHP框架刚刚提取的笨zip文件,试图在Aptana studio中运行welcome.php控制器。 (PHP 5)

+0

ru关闭你的PHP报价? – rabidmachine9 2010-09-02 22:15:45

+1

你正在采取什么步骤来获得这段代码?你确定你是通过index.php指导而不是直接访问这个文件吗? – treeface 2010-09-02 23:31:25

+3

@rabidmachine关闭php标签是可选的,有时它是有帮助检查了这一点http://us.php.net/basic-syntax.instruction-separation我不认为这是问题 – Brary 2010-09-03 00:03:57

回答

2

问题是我直接访问这个文件(比如'treeface'说的),但是使用这个路由生成的页面没有找到?

127.0.0.1:8000/test_ci/index.php/welcome

然后我安装WAMP和使用

localhost/test_ci/index.php/welcome

,这是工作!
不便之处!

0

好像Codeigniter在不同于'/'的文件夹中。如果您不更改index.php或config.php中的BASEPATH或系统根目录路径,则会导致问题。

检查index.php中“system”变量的第14-26行(?)。

/* 
|--------------------------------------------------------------- 
| SYSTEM FOLDER NAME 
|--------------------------------------------------------------- 
| 
| This variable must contain the name of your "system" folder. 
| Include the path if the folder is not in the same directory 
| as this file. 
| 
| NO TRAILING SLASH! 
| 
*/ 
    $system_folder = "system"; 

更改以反映系统文件夹和配置项的路径将肯定会找到您的控制器类。

4

无需定义类的构造函数。这是codeigniter 2.0或更高版本框架的代码。

class Welcome extends CI_Controller { 

    public function index() 
    { 
     $this->load->view('welcome_message'); 
    } 
} 
2

因为你使用的是代号为旧版本的CodeIgniter,这样使用:

class Hello extends CI_Controller 
{ 
    var $name; 
    var $color; 
    function Hello() 
    { 
     parent :: __construct(); 
     $this->name = "Name"; 
     $this->color = "red"; 
    } 
    function you() 
    { 
     $data["name"] = $this->name; 
     $data["color"] = $this->color; 
     $this->load->view("you_view", $data); 
    } 

} 
1

延长,而不是控制器 我有代码点火器同样的问题之前,我切换到是CI_Controller是CI_Controller