(PECL ev >= 0.2.0)
EvStat::__construct — 构造 EvStat 观察器对象
$path
,$interval
,$callback
,$data
= null
,$priority
= 0构造 EvStat 观察器对象并自动启动观察器。
示例 #1 监控 /var/log/messages 的更改
<?php
// 使用 10 秒更新间隔。
$w = new EvStat("/var/log/messages", 10, function ($w) {
echo "/var/log/messages changed\n";
$attr = $w->attr();
if ($attr['nlink']) {
printf("Current size: %ld\n", $attr['size']);
printf("Current atime: %ld\n", $attr['atime']);
printf("Current mtime: %ld\n", $attr['mtime']);
} else {
fprintf(STDERR, "`messages` file is not there!");
$w->stop();
}
});
?>