这是Server / Init.php:
spl_autoload_register(function($file) {
include str_replace('\\, '/', $file) . '.php';
});
$GLOBALS['config'] = $config;
$GLOBALS['patched'] = $patched;
$GLOBALS['crumbs'] = $crumbs;
$utils = new Utils();
$mysql = new MySQL();
$GLOBALS['utils'] = $utils;
$GLOBALS['mysql'] = $mysql;
问题似乎是尝试包含Utils.php,它位于classes文件夹中。这些是错误:
Warning: include(Utils.php): Failed to open stream: No such file or directory in C:/xampp/htdocs/server/Init.php on line 9
Warning: include(): Failed opening 'Utils.php' for inclusion (include_path='.;C:/xampp/php/PEAR') in C:/xampp/htdocs/server/Init.php on line 9
Fatal error: Class 'Utils' not found in C:/xampp/htdocs/server/Init.php on line 16
如果有帮助,这是Server / Classes / Utils.php:
class Utils {
public function writeRawOutput($str) {
echo $str;
}
public function writeOutput($msg, $type = null, $pref = null) {
$msg = strval($msg);
if($type == null && $pref == null)
echo "$msg \r\n";
elseif($type == null && $pref != null)
echo "[$pref] > $msg \r\n";
elseif($type != null && $pref == null)
echo "[$type] > $msg \r\n";
elseif($type != null && $pref != null)
echo "[$pref] [$type] > $msg \r\n";
}
public function getInput($str) {
$this->writeOutput($str);
$input = trim(fgets(STDIN));
return $input;
}
public function getConfig($path = null) {
if($path) {
$config = $GLOBALS['config'];
$path = explode('/', $path);
foreach($path as $bit) {
if(isset($config[$bit])) {
$config = $config[$bit];
}
}
return $config;
}
return false;
}
}
我做错了什么,如何解决这个问题?