Welcome Guest, Not a member yet? Register   Sign In
新建控制器出错了“A PHP Error was encountered”

class Index extends CI_Controller {

    public function index()

A PHP Error was encountered
Severity: Notice

Message: Undefined property: Index::$load

Filename: controllers/index.php

Line Number: 7

Fatal error: Call to a member function view() on a non-object in E:\AppServ\www\CodeIgniter\application\controllers\index.php on line 7

配置文件修改:$route['default_controller'] = "index";

User Guide - Reserved Names

Ummm. PHP is case sensitive. He named his class "Index" not "index"

[quote author="Basketcasesoftware" date="1308826981"]Ummm. PHP is case sensitive. He named his class "Index" not "index"[/quote]

Still, according to the user_guide this is a reserved word.

And according to "ci code syntax" class is first letter capitalized, isn't it?

the user guide uses the lower case specifically on that instance of a reserved word. The others are capitalized. That's not accidental. To PHP "class index" is not the same as "class Index". This might be an error in the manual. Wouldn't be the first time. Smile

Since your controller classes will extend the main application controller you must be careful not to name your functions identically to the ones used by that class, otherwise your local functions will override them. The following is a list of reserved names. Do not name your controller any of these:


You guys need to read the system/core/loader.php and CodeIgniter.php file to really understand what is going on in the background!

CodeIgniter doe's a lot of upper and lower case converting on the fly!


@InsiteFX - That's an understatement if I ever heard one. A detail that probably should be noted in that section of the manual.

Theme © iAndrew 2016 - Forum software by © MyBB