APPPATH codeigniter doesnt work on server

拜拜、爱过 提交于 2020-01-11 05:32:05

问题


I have a problem in codeigniter - after I upload it to the server I am requiring a file in a model from libraries folder

<?php
require_once(APPPATH.'libraries/MY_Model.php');
Class scroll_news_model extends MY_model
{
 public function __construct()
 {
    parent::__construct("scroll_news");
 }
}

this code was working fine in my localhost environment but I keep getting this error after I upload it:

Fatal error: require_once() [function.require]: Failed opening required 'application/libraries/MY_Model.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/arab2day/public_html/temp/arab2day/application/models/scroll_news_model.php on line 2


回答1:


If you are trying to extend the CI_Model class, MY_Model.php belongs in the /core directory rather than /libraries, and you don't need to include it - it will be loaded automatically when the base model class is loaded.

This is how extending core classes works, extending regular non-essential "libraries" is slightly different. Read more about it here:

http://codeigniter.com/user_guide/general/core_classes.html

As far as the literal problem goes, Lepidosteus makes a good point about case sensitivity and OS, I've run into this issue myself several times.




回答2:


Check the case of your file names; windows makes no difference between ABC.php and abc.php, but linux does.



来源:https://stackoverflow.com/questions/9242788/apppath-codeigniter-doesnt-work-on-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!