質問

Enter Image説明

次のディレクトリ構造を持ち、次のようにclasses/の中にすべてのクラスを入れて、両方のファイルを呼び出すheader.phpがあり、すべてのファイルが共有するその他の重要な設定があります。

今、このようにspl_autoload_register()を使用している場合:

spl_autoload_register(function($class){
        include 'classes/'. $class .'.class.php';
    });
.

inc/header.phpファイルの内部で、このheader.phpファイルからこのindexを呼び出してから、LocalHostでうまく機能しますが、すべてのスクリプトをLiveホストにアップロードすると、エラーが発生します。

Warning: include(classes/filehandler.class.php) [function.include]: failed to open stream: No such file or directory in /home/.../public_html/....com/inc/header.php on line 9 
.

Line 9spl_autoload_register()

です。

私はこれが起こるかもしれない方法、そして誰かがまったく考えを持っていることを願っています。

ありがとう

役に立ちましたか?

解決

私のコメントで何を意味するのかを示すには、このコードをindex.phpファイルに追加し、他のファイルからオートローダを削除します。

spl_autoload_register(function($class){
    $classesPath = dirname(__FILE__) . '/classes/';
    if (is_file($classFile = $classesPath . $class.'.class.php')) {
        include $classFile;
    }
});
.

for inc / header.php:

spl_autoload_register(function($class){
    $classesPath = dirname(__FILE__) . '/../classes/';
    if (is_file($classFile = $classesPath . $class.'.class.php')) {
        include $classFile;
    }
});
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top