PHP加载opcache扩展后,经常有文件由于OPcache缓存修改后不生效,写个脚本手动执行
每个文件一行,并用分号( ; )分割,例如:
App\Lib\Action\a.php;
App\Lib\Action\b.php;
/> CRM
/> Mobile
if(isset($_POST) && trim($_POST['files'])){
$file_arrs=explode(';',trim($_POST['files'],';')); //获取要刷新的文件数组
$app=trim($_POST['app']);
$root_path="/mnt/data/www/{$app}/"; //项目路径
//print_r($file_arrs);die;
foreach($file_arrs as $file){
if(trim($file)!=''){
$file=str_replace('\\','/',trim(trim($file),'/')); //替换Linux路径符号
$file_path=$root_path.$file; //完整文件路径
$result=opcache_invalidate($file_path); //刷新文件
if($result){
echo $file_path,'文件刷新成功
';
}else{
echo $file_path,'文件刷新失败,可能文件不存在
';
}
}
}
}