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

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

WBOY
Release: 2016-06-02 11:32:09
Original
1067 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
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template