3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $fo = fopen('lock.txt', 'r+'); if (flock($fo, LOCK_EX)) { // File was not locked, You have locked it successfully right now, do your logic flock($fo, LOCK_UN); // unlock file afer script logic } else { // File is locked right now, don't run script }
Output for 5.0.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: fopen(lock.txt): failed to open stream: No such file or directory in /in/YPSqu on line 2 Warning: flock() expects parameter 1 to be resource, boolean given in /in/YPSqu on line 3
Output for hhvm-3.12.0
Warning: No such file or directory in /in/YPSqu on line 2 Warning: flock() expects parameter 1 to be resource, boolean given in /in/YPSqu on line 3
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.2 - 4.4.9
Warning: fopen(lock.txt): failed to open stream: No such file or directory in /in/YPSqu on line 2 Warning: flock(): supplied argument is not a valid stream resource in /in/YPSqu on line 3
Output for 4.3.0 - 4.3.1
Warning: fopen(lock.txt) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/YPSqu on line 2 Warning: flock(): supplied argument is not a valid stream resource in /in/YPSqu on line 3