PHP SPL SplFileInfo FilterIterator 轮询文件删除
基于PHP spl 遍历文件删除过期的日志文件
一.定义PHP类 , 限制文件扩展 RecursiveFileFilterIterator.class.php
<?php class RecursiveFileFilterIterator extends FilterIterator { protected $ext = array("log","jpg","gif"); public function __construct($path) { parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path))); } public function accept() { $item = $this->getInnerIterator(); if ($item->isFile() && in_array(pathinfo($item->getFilename(), PATHINFO_EXTENSION), $this->ext)) { return TRUE; } } }