新建控制器出错了“A PHP Error was encountered” - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: 新建控制器出错了“A PHP Error was encountered” (/showthread.php?tid=42868) |
新建控制器出错了“A PHP Error was encountered” - El Forum - 06-22-2011 [eluser]Unknown[/eluser] Code: class Index extends CI_Controller { 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"; 地址是:http://www.qqsb.us/codeigniter/index.php/index/index/ 新建控制器出错了“A PHP Error was encountered” - El Forum - 06-22-2011 [eluser]osci[/eluser] User Guide - Reserved Names 新建控制器出错了“A PHP Error was encountered” - El Forum - 06-23-2011 [eluser]Basketcasesoftware[/eluser] Ummm. PHP is case sensitive. He named his class "Index" not "index" 新建控制器出错了“A PHP Error was encountered” - El Forum - 06-23-2011 [eluser]osci[/eluser] [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. EDIT: And according to "ci code syntax" class is first letter capitalized, isn't it? 新建控制器出错了“A PHP Error was encountered” - El Forum - 06-23-2011 [eluser]Basketcasesoftware[/eluser] 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. 新建控制器出错了“A PHP Error was encountered” - El Forum - 06-23-2011 [eluser]InsiteFX[/eluser] 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: Controller CI_Base _ci_initialize Default index 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 新建控制器出错了“A PHP Error was encountered” - El Forum - 06-23-2011 [eluser]Basketcasesoftware[/eluser] @InsiteFX - That's an understatement if I ever heard one. A detail that probably should be noted in that section of the manual. |