drl971115 2011-01-27 10:04
浏览 48
已采纳

PHP Autoloader和Unix区分大小写的文件系统

I have index.php

<?php
    include('_controller/Autoloader.php');
    Gold_Autoloader::init();

    $mysql = new Gold_MySQL();

_controller/Autoloader.php

<?php
class Gold_Autoloader
{

    public static $loader;

    public static function init()
    {
        if (self::$loader == NULL)
            self::$loader = new self();

        return self::$loader;
    }

    public function __construct()
    {
        spl_autoload_register(array($this, 'controller'));
        spl_autoload_register(array($this, 'resources'));
    }

    public function resources($className)
    {
        $className = preg_replace('#Gold_#', '', $className);
        $className = preg_replace('#_#', DIRECTORY_SEPARATOR, $className);

        set_include_path(PROJECT_ROOT . '_resources');
        spl_autoload_extensions('.php');
        spl_autoload($className);
    }

    public function controller($className)
    {
        $className = preg_replace('#Gold_#', '', $className);
        $className = preg_replace('#_#', DIRECTORY_SEPARATOR, $className);

        set_include_path(PROJECT_ROOT . '_controller');
        spl_autoload_extensions('.php');
        spl_autoload($className);
    }
}

And I have file _controller/MySQL.php with Gold_MySQL.class. On windows system this code is working and including MySQL.php, but on hosting this code not working ((

[Thu Jan 27 12:55:57 2011] [error] PHP Fatal error: Class 'Gold_MySQL' not found in /home/u91167/youd0main.com/www/index_.php on line 5

EDIT

How to make so that Unix could look at any files? Zend has no files with a lowercase letter.

  • 写回答

3条回答 默认 最新

  • doupin5408 2011-01-27 10:08
    关注

    Sounds like your filename is case sensitive and you're trying to load a file in the wrong case. i.e. you might need gold_mysql.php instead of Gold_MySql.php?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥30 数字信号处理实验报告
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要
  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改