我有以下文件结构:
cron.php /includes/functions.php /classes/ClassName.php
corn.php 包括functions.php 调用new ClassName()。functions.php 包含原始自动加载器:
function __autoload($class_name) {
require_once('classes/'.$class_name.'.php');
}
从浏览器调用 cron.php 时效果很好。但是,如果从 shell 运行它会给出“没有这样的文件或目录”的致命错误。我试图将 'classes/'.$class_name.'.php' 包装到 realpath() 函数中无济于事。请指教。