3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $testfile = dirname(__FILE__) . '/test.lock'; touch($testfile); $f1 = fopen($testfile, 'r'); echo $f1; echo var_export(flock($f1, LOCK_EX)); $f2 = fopen($testfile, 'r'); echo $f2; echo var_export(flock($f2, LOCK_EX | LOCK_NB));
Output for 5.0.0 - 7.1.0
Warning: touch(): Unable to create file /in/test.lock because Permission denied in /in/nS92E on line 4 Warning: fopen(/in/test.lock): failed to open stream: No such file or directory in /in/nS92E on line 6 Warning: flock() expects parameter 1 to be resource, boolean given in /in/nS92E on line 8 NULL Warning: fopen(/in/test.lock): failed to open stream: No such file or directory in /in/nS92E on line 10 Warning: flock() expects parameter 1 to be resource, boolean given in /in/nS92E on line 12 NULL
Output for 4.3.5 - 4.4.9
Warning: touch(): Unable to create file /in/test.lock because Permission denied in /in/nS92E on line 4 Warning: fopen(/in/test.lock): failed to open stream: No such file or directory in /in/nS92E on line 6 Warning: flock(): supplied argument is not a valid stream resource in /in/nS92E on line 8 false Warning: fopen(/in/test.lock): failed to open stream: No such file or directory in /in/nS92E on line 10 Warning: flock(): supplied argument is not a valid stream resource in /in/nS92E on line 12 false
Output for 4.3.2 - 4.3.4
Warning: touch(): Unable to create file /in/test.lock because Permission denied in /in/nS92E on line 4 Warning: fopen(/in/test.lock): failed to open stream: No such file or directory in /in/nS92E on line 6 Warning: flock(): supplied argument is not a valid stream resource in /in/nS92E on line 8 NULL Warning: fopen(/in/test.lock): failed to open stream: No such file or directory in /in/nS92E on line 10 Warning: flock(): supplied argument is not a valid stream resource in /in/nS92E on line 12 NULL
Output for 4.3.0 - 4.3.1
Warning: touch() [http://www.php.net/function.touch]: Unable to create file /in/test.lock because Permission denied in /in/nS92E on line 4 Warning: fopen(/in/test.lock) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/nS92E on line 6 Warning: flock(): supplied argument is not a valid stream resource in /in/nS92E on line 8 NULL Warning: fopen(/in/test.lock) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/nS92E on line 10 Warning: flock(): supplied argument is not a valid stream resource in /in/nS92E on line 12 NULL