You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

When you need to add some text strings to a certain text file, the common approach is to open file in append mode, write additional strings, and close that file. PHP provides a straightforward and simple function can do that by one function.


$txt = date("Y-m-d H:i:s") . ": service process does not exist\n";
$myfile = file_put_contents('logs.txt', $txt.PHP_EOL , FILE_APPEND | LOCK_EX);


  • No labels