Home  >  Article  >  Backend Development  >  PHP的fwrite会并发执行

PHP的fwrite会并发执行

WBOY
WBOYOriginal
2016-06-13 13:06:19835browse

PHP的fwrite能并发执行?

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$f2 = fopen('file/index.txt','w');
fwrite($f2,$h.$old);
fclose($f2);


例如: 制作留言板. 没有使用MySQL等软件. 直接把留言写入一个.txt文件里.

如果在高峰时期, 同一秒内有50,000人留言. 
www.dbscripts.net/guestbook/demo/


PHP能并发执行, 不会出错?

------解决方案--------------------
出什么错?
你使用写方式打开的
file/index.txt 永远都是最后一个写的内容
------解决方案--------------------
写方式会覆盖吧
------解决方案--------------------
不知道.可能传说中的文件锁是解决之道
Statement:
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