pay/includes/autoloader.php
2025-11-28 10:08:12 +08:00

33 lines
736 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
*
* 自动载入函数
*/
class Autoloader
{
/**
* 向PHP注册在自动载入函数
*/
public static function register()
{
spl_autoload_register(array(new self, 'autoload'));
}
/**
* 根据类名载入所在文件
*/
public static function autoload($className)
{
// DIRECTORY_SEPARATOR目录分隔符linux上就是/ windows上是\
$filePath = __DIR__ . DIRECTORY_SEPARATOR . $className;
$filePath = str_replace('\\', DIRECTORY_SEPARATOR, $filePath) . '.php';
if (file_exists($filePath)) {
require_once $filePath;
return true;
} else {
return false;
}
}
}