我使用下面的代码片段自动加载的类从几个文件夹:spl_autoload_register()与多个文件夹
// Check if the autoload configuration file exists
if(is_file("configuration/autoload")) {
// Extract the listed folders from the configuration file
$folders = explode("\n", file_get_contents("configuration/autoload"));
// Prepend the base path to the extracted folder paths
array_unshift($folders, get_include_path());
// Configure the folders in which to attempt class autoloading
set_include_path(implode(PATH_SEPARATOR, $folders));
// Configure the file extensions that should be autoloaded
spl_autoload_extensions(".php");
// Administer the attempt to autoload classes
spl_autoload_register();
}
的几个文件夹的文件中列出像这样:
core/utility
core/factory
core/modules
core/classes
core/classes/form
core/classes/form/fields
frontend
它的工作原理像本地的魅力,但我不能让它在我的在线服务器上工作(我做了CHMOD所涉及的所有文件&文件夹)。我想在设置包含路径的时候,事情出错了,但我似乎无法围绕它来包裹我的头。
任何想法?
感谢
大多数情况下,当我听到服务器上的自动加载中断时,这是因为服务器通常在运行Linux并且区分大小写的文件系统。 OS X和Windows在默认情况下不区分大小写。 所以问题可能只是你试图自动加载一个不同于文件名的外壳的类。 – Evert
@Evert我为这两个类和它们的文件名应用相同的格式设置 –