与CI

2011-08-11 130 views
0

我想我的新的手在代码点火器,并有这个问题拿出一个登记控制器上工作。与CI

致命错误(!):类 '控制' 用C未找到:\ WAMP \ WWW \ kowmanager \ SYSTEM \程序\控制器\ user.php的第2行 调用堆栈

时间记忆功能定位

1 0.0007 695640 {main}().. \ index.php:0 2 0.0021 782824 require_once('C:\ wamp \ www \ kowmanager \ system \ core \ CodeIgniter.php').. \ index.php :201 3 0.0181 1938352 include('C:\ wamp \ www \ kowmanager \ system \ application \ controllers \ user.php').. \ CodeIgniter.php:248

<?php 
class User extends Controller { 

function User() 
{ 
    parent :: Controller(); 
    $this->view_data['base_url'] = base_url(); 
} 

function index() 
{ 
    $this->register(); 
} 

function register() 
{ 
    $this->load->view('view_register', $this->view_data); 
} 

} 
?> 

编辑:

我改变了类用户扩展是CI_Controller但现在我得到这样的:

致命错误:调用未定义的方法是CI_Controller ::控制器()在C:\ WAMP \ WWW \ kowmanager \ SYSTEM \应用\控制器\第6行

编辑2 user.php的:

这是我的新的代码。即时得到致命错误:调用未定义方法是CI_Controller ::用户()在C:\瓦帕\ WWW \ kowmanager \ SYSTEM \应用\控制器\上线user.php的6

<?php 
class User extends CI_Controller { 

function User() 
{ 
    parent :: User(); 
    $this->view_data['base_url'] = base_url(); 
} 

function index() 
{ 
    $this->register(); 
} 

function register() 
{ 
    $this->load->view('view_register', $this->view_data); 
} 

} 
?> 
+0

Ver 2.0。1以后,构造函数是__construct()。我编辑了我的答案。这应该有帮助 – looneydoodle

回答

1

检查此链接。 Codeigniter constructors. What is the difference?

看来您使用的是CodeIgniter 2+和PHP 5.旧的构造函数方法不再适用。

啊,因为我认为你正在使用PHP 5

function User() 
{ 
    parent :: User(); 
    $this->view_data['base_url'] = base_url(); 
} 

您应该改用__construct()。

function User() 
{ 
    parent::__construct(); 
    $this->view_data['base_url'] = base_url(); 
} 

或者替换函数名称,因此覆盖父构造函数方法的可读性更强。

function __construct() 
{ 
    parent::__construct(); 
    $this->view_data['base_url'] = base_url(); 
} 
+0

红色留给达纳的评论。 –

1

的userguide使用该行:

class User extends CI_Controller {

不必在目前快速访问我的文件CI,但我会用什么userguide说去。

+0

这也没有帮助。出于某种原因,我复制了这段视频中的确切代码以适应框架,并且仍然在做同样的事情。 –

+0

你能确认你使用了哪个视频吗? – Zomxilla

+0

http://www.youtube.com/user/Verbloten#p/u/42/bGCJNfE0szs对不起,我认为我包括它,但我也更新了我的帖子。 –

1

这是

class User extends CI_Controller 
+0

查看编辑编号2 –

+1

好的,已编辑。新版本中的构造函数必须是__construct。 – looneydoodle

+1

此外,坦克认证可能是一个更好的方法。 – looneydoodle

0

的问题是,我应该已经采取了对构造函数的代码

function __construct() 
{ 
    parent ::__construct(); 
    $this->view_data['base_url'] = base_url(); 
} 

,而不是你的函数用户()

而且,我的表单打开标记$ baseUrl变量。