首页 > Web开发 > 详细

php写文件操作

时间:2015-04-16 17:12:26      阅读:201      评论:0      收藏:0      [点我收藏+]
	function writeLog($file, $msg, $mode=‘a+‘)
	{
		$fp = fopen($file, $mode);
		if(flock($fp, LOCK_EX))
		{
			fwrite($fp, $msg);
			fflush($fp);
			flock($fp, LOCK_UN);
		}
		else
			echo "Couldn‘t get the lock<br/>";
		fclose($fp);
	}

	$file = ‘zzb.log‘;
	writeLog($file, "1. this is the first message\n");
	writeLog($file, "2. this is the first message\n");
	writeLog($file, "3. this is the first message\n");
	writeLog($file, "--------------------\n\n");

  

php写文件操作

原文:http://www.cnblogs.com/joeblackzqq/p/4432543.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!