//获取全部的路径

 function tree(&$arr_file, $directory, $dir_name='')
{

    $mydir = dir($directory);
    while($file = $mydir->read())
    {
        if((is_dir("$directory/$file")) AND ($file != ".") AND ($file != ".."))
        {
            tree($arr_file, "$directory/$file", "$dir_name/$file");
        }
        else if(($file != ".") AND ($file != ".."))
        {
            $arr_file[] = "./wiseway_pc$dir_name/$file";
        }
    }
    $mydir->close();
}
$arr_file = array();
tree($arr_file, "./wiseway_pc");

//遍历路基读取文件
foreach($arr_file as $list){
            $str = "/data/wwwroot/wiseway/data/tpl_cache/";//指定字符串
            file_put_contents("./1.txt",$list.PHP_EOL, FILE_APPEND);  //写入txt文件当做日志记录,发生错误时可以查看

            //判断文件是否为图片
            $mimetype = exif_imagetype($list);
            if($mimetype != IMAGETYPE_GIF || $mimetype != IMAGETYPE_JPEG || $mimetype != IMAGETYPE_PNG || $mimetype != IMAGETYPE_BMP){
            $content = file_get_contents($list);  //获取文件内容
            if(substr_count($content,$str)>0){//如果文件名包含该字符串
                unlink($list);  //删除文件
            }
            }
     }