“PHP Append Line to File” Respostas de código

PHP Appender para arquivar

// LOCK_EX will prevent anyone else writing to the file at the same time
// PHP_EOL will add linebreak after each line
$txt = "data-to-add";
$myfile = file_put_contents('logs.txt', $txt.PHP_EOL , FILE_APPEND | LOCK_EX);

// Second option is this
$myfile = fopen("logs.txt", "a") or die("Unable to open file!");
$txt = "user id date";
fwrite($myfile, "\n". $txt);
fclose($myfile);
MeVyom

PHP Append Line to File

file_put_contents("filename.txt","new line to appended\n",FILE_APPEND);
Friendly Hawk

Anexando o arquivo txt de php

$log_content="This line is logged on 2020-08-14 09:55:00";
$myfile = fopen("log.txt", "a") or die("Unable to open file!");
fwrite($myfile, $log_content);
fclose($myfile);
Embarrassed Eagle

Respostas semelhantes a “PHP Append Line to File”

Perguntas semelhantes a “PHP Append Line to File”

Mais respostas relacionadas para “PHP Append Line to File” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código