输入banner图图片脚本导航/分类

php高并发访问写文件

  1. function write ( $data )
  2. {
  3. $return = false;
  4. if ( $handle = @fopen ( 'error.txt','a+' ) )
  5. {
  6. $i=0;
  7. while ( !flock ( $handle,2 ) && $i++ < 3 )
  8. {
  9. usleep ( 500000 );
  10. }
  11. if ( $i < 3 && fwrite ( $handle,$data . "\r\n" ) )
  12. {
  13. flock ( $handle,3 );
  14. $return = true;
  15. }
  16. fclose ( $handle );
  17. }
  18. return $return;
  19. }

php