加载类EWSType_FindItemType(php ews)时发生致命错误
我从来没有真正玩过类,但我希望在atm上使用的页面 我的主文件是通过include调用5个“root”php文件加载类EWSType_FindItemType(php ews)时发生致命错误,php,class,class-design,exchangewebservices,Php,Class,Class Design,Exchangewebservices,我从来没有真正玩过类,但我希望在atm上使用的页面 我的主文件是通过include调用5个“root”php文件 include ("php-ews/ExchangeWebServices.php"); include ("php-ews/EWS_Exception.php"); include ("php-ews/EWSType.php"); include ("php-ews/NTLMSoapClient.php"); include ("php-ews/NTLMStream.php");
include ("php-ews/ExchangeWebServices.php");
include ("php-ews/EWS_Exception.php");
include ("php-ews/EWSType.php");
include ("php-ews/NTLMSoapClient.php");
include ("php-ews/NTLMStream.php");
但是,在本例中,这些用户抱怨这些子文件夹中的文件不包括在内
Fatal error: Class 'EWSType_FindItemType' not found in C:\wamp\www\intranet\dashboard\mailtest.php on line 19
我尝试将上面的文件包含在EWSType.php文件中,但它抱怨下一个文件没有包含。我尝试过在文件夹中包含任何.php的方法,但这不起作用
我想我只是想加载一个错误的类,不知道是否有人可以给我指路 不要手动加载类,而是尝试自动加载类。这样,您就不必担心保留包含的列表。自动加载器会帮你的。 如果类文件的调用与类本身的调用相同,那么应该很容易 看 详情请参阅
function ews_autoloader($className) {
if($className != 'EWS_Exception') {
$classPath = str_replace('_','/',$className);
}
if(file_exists("php-ews/{$classPath}.php") {
include("php-ews/{$classPath}.php");
}
}
spl_autoload_register('ews_autoloader');
设法拼凑了一点代码来包含主文件夹文件
$dir = '/wamp/www/intranet/dashboard/php-ews/EWSType/';
$files1 = scandir($dir);
foreach ($files1 as $value) {
if(preg_match('/\.php$/i', $value)){
$inc = "php-ews/EWSType/";
$inc .= $value;
include ($inc);
}}
不幸的是,这些文件的命名不适合该函数,存储库位于此处,用于文件名@Xand94:所以我对其进行了一些改进;)