<?php

$path = "/tmp/test.txt";

function print_file()
{
	echo("\n ****");
	echo(file_get_contents($path));
	echo("\n");
}

// create base and event
$famd = fam_open();
if ($famd === FALSE) {
	print("could not connect to famd\n");
}

$mon = fam_monitor_file($famd, $path);
if ($mon === FALSE) {
	print("failed to setup file monitor\n");
}

while(TRUE) {
	$result = fam_next_event($famd);
	if ($result['code'] == FAMChanged) {
		print_file();
	}
}
?>

