“PHP Append -Zeile zur Datei angehängt” Code-Antworten

PHP an der Datei anhängen

// 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 -Zeile zur Datei angehängt

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

Anhang txtdatei von 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

Ähnliche Antworten wie “PHP Append -Zeile zur Datei angehängt”

Fragen ähnlich wie “PHP Append -Zeile zur Datei angehängt”

Weitere verwandte Antworten zu “PHP Append -Zeile zur Datei angehängt” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen