I'm using the PHP function file_put_contents() to put some content into a txt file. The example in the docs doesn't finish using fclose(), should I close the file or it's not necessary?
I'm doing this:
$root = $_SERVER['DOCUMENT_ROOT'];
$log = $root.'/logs/logsContenido.txt';
$agregadoLog = "texto a agregar";
file_put_contents($log, $agregadoLog, FILE_APPEND | LOCK_EX);
And just that. I don't close anything.
Should I rather do something like:
$root = $_SERVER['DOCUMENT_ROOT'];
$log = $root.'/logs/logsContenido.txt';
$agregadoLog = "texto a agregar";
$file = file_put_contents($log, $agregadoLog, FILE_APPEND | LOCK_EX);
fclose($file);