<?php
// 定義日志文件路徑
$logPath = '/var/log/';
// 創(chuàng)建 RecursiveTreeIterator 對象
$logIterator = new RecursiveTreeIterator(
new RecursiveDirectoryIterator($logPath)
);
// 遍歷日志文件
foreach ($logIterator as $logFile) {
// 如果是文件,則讀取文件內(nèi)容
if ($logFile->isFile()) {
$logContent = file_get_contents($logFile->getPathname());
// 對日志內(nèi)容進行處理
// ...
}
}