Good,
I'm creating a function that will create a new log.txt, if already exist just write the new data.
But it is giving errors, since I am testing, and I click REFRESH to the browser it only did this.
ficheiro log.txt \
ola
/n
I wanted to fix the problems and add more security in the files
$path_log = 'inc/logs/log1.txt';
$log_msg = 'ola'. PHP_EOL;
log_editor($path_log, $log_msg);
function log_editor($path_log, $log_msg) {
$Handle = fopen($path_log, 'wb');
if (file_exists($path_log)) {
fwrite($Handle, $log_msg. '\n');
//file_put_contents($file, $contents);
fclose($Handle);
} else {
fwrite($Handle, $log_msg);
fclose($Handle);
}
}
Where am I going wrong ...?