Information Systems



Log files in php

Sometimes you want to write to a log file in PHP. There are many ways to do this. One way is this.

function logFile($line)
{
$f = fopen ($_SERVER['DOCUMENT_ROOT']."/logs/log.txt", "a");
fwrite($f, $line."\n");
fclose($f);
}