function writeLog($file, $msg, $mode='a+')
{
$fp = fopen($file, $mode);
if(flock($fp, LOCK_EX))
{
fwrite($fp, $msg);
fflush($fp);
flock($fp, LOCK_UN);
}
else
echo "Couldn't get the lock<br/>";
fclose($fp);
} $file = 'zzb.log';
writeLog($file, "1. this is the first message\n");
writeLog($file, "2. this is the first message\n");
writeLog($file, "3. this is the first message\n");
writeLog($file, "--------------------\n\n");