From a2d43b86b0092af954bbdc95b4312cbb7e182e79 Mon Sep 17 00:00:00 2001 From: Anyon Date: Sat, 3 Nov 2018 09:20:32 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=AD=A3=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=BC=95=E5=85=A5=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include.php b/include.php index 06fd3b2..e88c70e 100644 --- a/include.php +++ b/include.php @@ -13,13 +13,15 @@ // +---------------------------------------------------------------------- spl_autoload_register(function ($classname) { - $filename = __DIR__ . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php'; - if (file_exists($filename)) { - if (stripos($classname, 'WeChat') === 0) include $filename; - elseif (stripos($classname, 'WeMini') === 0) include $filename; - elseif (stripos($classname, 'AliPay') === 0) include $filename; - elseif (stripos($classname, 'WePay') === 0) include $filename; - elseif ($classname === 'We') include $filename; + $pathname = __DIR__ . DIRECTORY_SEPARATOR; + $filename = str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php'; + if (file_exists($pathname . $filename)) { + foreach (['WeChat', 'WeMini', 'AliPay', 'WePay', 'We'] as $prefix) { + if (stripos($classname, $prefix) === 0) { + include $pathname . $filename; + return true; + } + } } return false; }); \ No newline at end of file