I have a code in which I keep a log with the activity register of the users in my intranet, and I want each user to be on a different line but it does not make the line break.
$nowtimename = gmdate('Y-m-d h:i:s \G\M\T', time());
$fp = fopen ("logs.txt", "a");
fwrite ($fp, $_SESSION["usuario"]);
fwrite ($fp, ";");
fwrite ($fp, $_SESSION["privilegio"]);
fwrite ($fp, ";");
fwrite ($fp, $nowtimename);
fwrite ($fp, \n);
fclose ($fp);
?>
$nowtimename = gmdate('Y-m-d h:i:s \G\M\T', time());
$fp = fopen ("logs.txt", "a");
fwrite ($fp, $_SESSION["usuario"]);
fwrite ($fp, ";");
fwrite ($fp, $_SESSION["privilegio"]);
fwrite ($fp, ";");
fwrite ($fp, $nowtimename);
fwrite ($fp, "\n");
fclose ($fp);
?>
I tried it both ways and it doesn't work for me.
You must write the
\n
between single quotes and not with doubles:If this doesn't work for you, try
PHP_EOL
it, I'll leave you the manual .You have to do it with double quotes, with single quotes it doesn't work.