PHP check if file locked with flock()?

后端 未结 1 777
借酒劲吻你
借酒劲吻你 2021-01-04 03:05

Will fopen() fail if a file exists, but is currently locked with LOCK_EX?

Or do I have to open it, and then try and set a lock, in

1条回答
  •  爱一瞬间的悲伤
    2021-01-04 03:12

    flock() doesn't actually prevent you from reading/writing to a file, it only allows you to "communicate" the ideas of locking to other scripts. You can detect if there is a lock on a file using the snippet you posted.

    0 讨论(0)
提交回复
热议问题