我一直使用包含,如果我想引入一个类,我从来没有使用过自动加载器功能。当我出于某种原因使用这个函数时,我会继续得到错误。
警告: /home/mjcrawle/phpfiles/preprod/test/index.php (include_once/user.class.php):未能打开流:在第6行的/home/mjcrawle/phpfiles/preprod/test/index.php中没有这样的文件或目录警告: include_once():打开‘Class /user.class.php’失败,以便将(include_path='.:/usr/share/php:/usr/share/pear')包含在第6行的/home/mjcrawle/phpfiles/preprod/test/index.php中,致命错误:在/home/mjcrawle/中找不到类'User‘phpfiles/preprod/test/index.php,第42行“
这就是我的php包含的内容。
require_once('classes/ registereduser.class.php'); 这是我无法工作的自动机。我班上的第一个字母是上限,这就是为什么我用字符串来降低的原因。
function autoloader($class){
include_once('classes/'.strtolower($class).'.class.php');
}spl_autoload_register(autoloader);
我需要一些帮助,知道我在这方面出了什么问题,我搞不懂。
发布于 2012-09-23 13:17:21
一些提示:-目录“类”不在包含路径中。因为php会在那里搜索autoload,你就知道出了什么问题.-使用set_include_path函数将类目录添加到包含路径中。
我不能详细说明,因为我正在用我的手机和它的键盘是一个痛苦。
https://stackoverflow.com/questions/12552571
复制相似问题