php如何解决多线程同时读写一个文件的问题
<?php header("content-type:text/html;charset=utf-8"); $fp = fopen("lock.txt","w+"); if(flock($fp, LOCK_EX)){// 进行排它型锁定 fwrite($fp,"Write something here\n"); flock($fp, LOCK_UN);// 释放锁定 }else{ echo "Couldn't lock the file !"; } fclose($fp); ?>
起点在哪,或许选择不了。重要的是,你追求的终点在哪!