1
Good,
I am creating a Function that will create a new log.txt, if you already exist just write the new data.
But it is giving errors, since I am testing, and I click REFRESH to the browser it just 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...?
Did I get my answer, friend? That’s right?
– Andrei Coelho
Hello Snoopy12, I know you are not obliged to evaluate my answer. But take into account that no one at Sopt is required to answer questions either. And what drives us to do this is the reward given to us by the "Builders". If there is an error in my answer, share it with me! Even if you didn’t like my answer, my didactics or my "aproach". Any questions are available.
– Andrei Coelho