此函数旨在执行对已包含文件的过滤
<?php
function setIncludeFiles($arrayInc = array()){
$incFiles = get_included_files();
if((count($arrayInc)>0)&&(count($incFiles)>0)){
$aInt = array_intersect($arrayInc,$incFiles);
if(count($aInt)>0){
return false;
}elseif(count($aInt)<1) {
foreach($arrayInc as $inc){
if(is_file($inc))
include($inc);
else{
return false;
}
}
}
}else{
return false;
}
}
?>
用法
<?php
$toBeInclude = array('/data/your_include_files_1.php',
'/data/your_include_files_2.php',
'/data/your_include_files_3.php',
);
setIncludeFiles($toBeInclude);
?>
如果出现错误,则返回 false。