// four possible unique names, for instances of the script... 2-3 of them get the same file name.. WHY !? do { $fileName = $_SERVER['DOCUMENT_ROOT'].'/test'.mt_rand(0,3).'.txt'; $fileHandle = @fopen($fileName,'x'); echo $fileName.'
'; } while ($fileHandle === false); echo '^ this is it
'; sleep(10); // increase running time of the script to force collisions with the other instances