autoload.phpがあります。これは私のクラスを自動ロードするために実行されています。メインフォルダー内のすべてのphpファイルをautoとしてautoload.phpに含めたい。
好き:
include_to("index.php, example.php, ............... , other.php");
その間、私はphpの実行スタイルを知っています。
それは間違っている。
代わりにspl_autoload_register()
、ファイルをロードするオートローダーを作成するために使用する必要があります。使用するクラスが見つからない場合。
spl_autoload_register(function( $className ){
$filepath = '/path/to/files/' . strtolower( $className ) . '.php';
if ( !file_exists( $filepath ) )
{
$message = "Cannot load class: $className. ";
$message .= "File '$filepath' not found!";
throw new Exception( $message );
}
require $filepath;
});
auto_prepend_file設定を使用して、すべてのスクリプトにファイルを含めることができます。