为什么此构造函数无法在代码Igniter中加载? [英] Why is this constructor failing to load in Code Igniter?

查看:181
本文介绍了为什么此构造函数无法在代码Igniter中加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php
class Blog extends CI_Controller {
    function Blog() {
        parent::CI_Controller();
    }
}



我试图在代码Igniter中创建一个构造函数对我的类'Blog'和上面的代码给我一个致命错误:

I'm trying to create a constructor in Code Igniter for my class 'Blog' and the above code is giving me a fatal error:


致命错误:调用未定义的方法

中的CI_Controller :: CI_Controller()C:\ xampp\htdocs\mysites\blog\application\controllers\blog.php
第5行

Fatal error: Call to undefined method CI_Controller::CI_Controller() in C:\xampp\htdocs\mysites\blog\application\controllers\blog.php on line 5

如何解决此问题?

(我正在通过在线视频教程代码点火器网站,但我认为教程是大约2年过时,因为一些事情不工作,当我按照他们完全如视频中所示,这是其中之一 - 视频的链接是在这里 - 我在教程结束时遇到这个问题约8分钟)

(I'm going through a online video tutorial on the official code igniter website but I think the tutorial is about 2 years out of date as some of the things are not working when I follow them exactly as shown in the video, this being one of them - the link to the video is here - I encounter this problem towards the end of the tutorial about 8 minutes in)

推荐答案

应该是这样...

<?php
class Blog extends CI_Controller {

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

}

是基于1.7.2,它有一个核心的php4,没有使用php5 __ construct()构建类构造函数的方法。 Codeigniter 2.0.0有一个php5核心并使用它。

The tutorial you are probably going through is based on 1.7.2 which had a core of php4 which did not use the php5 __construct() method of building Class constructors. Codeigniter 2.0.0 has a php5 core and uses it.

这篇关于为什么此构造函数无法在代码Igniter中加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆