码迷,mamicode.com
首页 > Web开发 > 详细

php写文件操作

时间:2015-04-16 17:14:07      阅读:143      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!