I'm doing a web project in php to monitor with ping the network assets in my work I have a file named 'log.txt' in the root of my project that is fed with log information with date, time, ip etc. Line by line. Here's an example:
function functionLog($vSetor, $vIp, $vTaxa, $vPorta) {
$fp = fopen("log.txt", "a");
$dataLog = date("d/m/Y");
date_default_timezone_set('America/Belem');
$horaLog = date("H:i:s");
fwrite($fp, $dataLog . ' ' . $horaLog . ' ' . $vSetor . ' ' . $vIp . ' ' . $vTaxa . 'ms' . ' ' . $vPorta . "\r\n");
fclose($fp);
}
?>
But there comes a time when this file is too full of log information and need to empty with just one click
My question is: how can I call a function inside an html button so that the file is zeroed, that is, all the lines in the 'log.txt' file are deleted