Home > Backend Development > PHP Tutorial > php-帮我看看下面的为啥不对,设置文件大小,当输入数据超过1M时就会覆盖前面的,显示最新1M的数据

php-帮我看看下面的为啥不对,设置文件大小,当输入数据超过1M时就会覆盖前面的,显示最新1M的数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-02 11:32:09
Original
1104 people have browsed it

php

function writeLog($msg){
$max_size = 1000000;
$logFile = 'log.txt';
date_default_timezone_set('Asia/Chongqing');
$data = date('Y-m-d H:i:s').' >>> '.$msg."\r\n";
$size=filesize($logFile);
$temp=strlen($data);
if($size+$temp>$max_size){
$input=$data++;
$input = substr($input,(strlen($input)-$max_size));

<code>}file_put_contents($logFile,$data,FILE_APPEND );</code>
Copy after login

}
writeLog('hello');
?>

Related labels:
php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template