I have txt file, which keeps 1 as in the following query to take the contents from txt and +1
function analitic(){
$file = fopen(TEMPLATEPATH . "/analitic.txt", "w");
$txt = $_POST['data']; //$txt = 1
fwrite($file, $txt);
fclose($file);
}
And how to add a date in the txt file? And if the date is different, save the data in the next line?
Thank you google translate :)
This will work...
file_put_contents(TEMPLATEPATH."/analitic.txt",PHP_EOL.date('c').PHP_EOL,FILE_APPEND);
Some think like this:
function my_action_myFunc(){
$data = $_POST['data'];
$date = date('d.m.Y');
$file = file_get_contents(TEMPLATEPATH."/analitic.txt",null,null, 10);
settype($file, "integer");
settype($data, "integer");
$a = $file+$data;
file_put_contents(TEMPLATEPATH."/analitic.txt",$date.PHP_EOL.$a);
wp_die();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.