Will fopen() fail if a file exists, but is currently locked with LOCK_EX?
fopen()
LOCK_EX
Or do I have to open it, and then try and set a lock, in
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.
flock()