PHP版本: 复制代码 代码如下: /** * 删除7天前的日志 * @param $logPath */ function del7daysAgoLog($logPath) { if(empty($logPath))return; $handle = opendir($logPath); while(($file = readdir($handle)) !== false){ $pos = strpos($file, ‘.log’); if ($pos !== false && (strtotime(“-1 week”) > fileatime($logPath . $file))) { u