3v4l.org

run code in 300+ PHP versions simultaneously
<?php touch("testfile"); function mylock() { $F1 = fopen("testfile","r"); if (flock($F1,LOCK_EX|LOCK_NB)) echo "First lock OK\n"; else echo "First lock FAIL\n"; $F2 = fopen("testfile","r"); if (flock($F2,LOCK_EX|LOCK_NB)) echo "Second lock OK\n"; else echo "Second lock FAIL\n"; } mylock(); echo "Function returned.\n"; mylock(); unlink("testfile");
Output for 8.3.0 - 8.3.7
Warning: touch(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 2 Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 5 Warning: fopen(testfile): Failed to open stream: Operation not permitted in /in/UjBS6 on line 5 Fatal error: Uncaught TypeError: flock(): Argument #1 ($stream) must be of type resource, false given in /in/UjBS6:6 Stack trace: #0 /in/UjBS6(6): flock(false, 6) #1 /in/UjBS6(11): mylock() #2 {main} thrown in /in/UjBS6 on line 6
Process exited with code 255.
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Warning: touch(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 2 Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 5 Warning: fopen(testfile): Failed to open stream: Operation not permitted in /in/UjBS6 on line 5 Fatal error: Uncaught TypeError: flock(): Argument #1 ($stream) must be of type resource, bool given in /in/UjBS6:6 Stack trace: #0 /in/UjBS6(6): flock(false, 6) #1 /in/UjBS6(11): mylock() #2 {main} thrown in /in/UjBS6 on line 6
Process exited with code 255.
Output for 8.0.13
Warning: touch(): Unable to create file testfile because Read-only file system in /in/UjBS6 on line 2 Warning: fopen(testfile): Failed to open stream: No such file or directory in /in/UjBS6 on line 5 Fatal error: Uncaught TypeError: flock(): Argument #1 ($stream) must be of type resource, bool given in /in/UjBS6:6 Stack trace: #0 /in/UjBS6(6): flock(false, 6) #1 /in/UjBS6(11): mylock() #2 {main} thrown in /in/UjBS6 on line 6
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26, 7.4.33
Warning: touch(): Unable to create file testfile because Read-only file system in /in/UjBS6 on line 2 Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock() expects parameter 1 to be resource, bool given in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock() expects parameter 1 to be resource, bool given in /in/UjBS6 on line 8 Second lock FAIL Function returned. Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock() expects parameter 1 to be resource, bool given in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock() expects parameter 1 to be resource, bool given in /in/UjBS6 on line 8 Second lock FAIL Warning: unlink(testfile): Read-only file system in /in/UjBS6 on line 15
Output for 7.3.16 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.32
Warning: touch(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 2 Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 5 Warning: fopen(testfile): failed to open stream: Operation not permitted in /in/UjBS6 on line 5 Warning: flock() expects parameter 1 to be resource, bool given in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 7 Warning: fopen(testfile): failed to open stream: Operation not permitted in /in/UjBS6 on line 7 Warning: flock() expects parameter 1 to be resource, bool given in /in/UjBS6 on line 8 Second lock FAIL Function returned. Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 5 Warning: fopen(testfile): failed to open stream: Operation not permitted in /in/UjBS6 on line 5 Warning: flock() expects parameter 1 to be resource, bool given in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 7 Warning: fopen(testfile): failed to open stream: Operation not permitted in /in/UjBS6 on line 7 Warning: flock() expects parameter 1 to be resource, bool given in /in/UjBS6 on line 8 Second lock FAIL Warning: unlink(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 15
Output for 7.2.29 - 7.2.33
Warning: touch(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 2 Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 5 Warning: fopen(testfile): failed to open stream: Operation not permitted in /in/UjBS6 on line 5 Warning: flock() expects parameter 1 to be resource, boolean given in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 7 Warning: fopen(testfile): failed to open stream: Operation not permitted in /in/UjBS6 on line 7 Warning: flock() expects parameter 1 to be resource, boolean given in /in/UjBS6 on line 8 Second lock FAIL Function returned. Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 5 Warning: fopen(testfile): failed to open stream: Operation not permitted in /in/UjBS6 on line 5 Warning: flock() expects parameter 1 to be resource, boolean given in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 7 Warning: fopen(testfile): failed to open stream: Operation not permitted in /in/UjBS6 on line 7 Warning: flock() expects parameter 1 to be resource, boolean given in /in/UjBS6 on line 8 Second lock FAIL Warning: unlink(): open_basedir restriction in effect. File(testfile) is not within the allowed path(s): (/tmp:/in:/etc) in /in/UjBS6 on line 15
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0
Warning: touch(): Unable to create file testfile because Permission denied in /in/UjBS6 on line 2 Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock() expects parameter 1 to be resource, boolean given in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock() expects parameter 1 to be resource, boolean given in /in/UjBS6 on line 8 Second lock FAIL Function returned. Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock() expects parameter 1 to be resource, boolean given in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock() expects parameter 1 to be resource, boolean given in /in/UjBS6 on line 8 Second lock FAIL Warning: unlink(testfile): No such file or directory in /in/UjBS6 on line 15
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Warning: touch(): Unable to create file testfile because Permission denied in /in/UjBS6 on line 2 Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 8 Second lock FAIL Function returned. Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile): failed to open stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 8 Second lock FAIL Warning: unlink(testfile): No such file or directory in /in/UjBS6 on line 15
Output for 4.3.1
Warning: touch() [http://www.php.net/function.touch]: Unable to create file testfile because Permission denied in /in/UjBS6 on line 2 Warning: fopen(testfile) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 8 Second lock FAIL Function returned. Warning: fopen(testfile) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 8 Second lock FAIL Warning: unlink(testfile) [http://www.php.net/function.unlink]: No such file or directory in /in/UjBS6 on line 15
Output for 4.3.0
Warning: touch() [http://www.php.net/function.touch]: Unable to create file testfile because Read-only file system in /in/UjBS6 on line 2 Warning: fopen(testfile) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 8 Second lock FAIL Function returned. Warning: fopen(testfile) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/UjBS6 on line 5 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 6 First lock FAIL Warning: fopen(testfile) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /in/UjBS6 on line 7 Warning: flock(): supplied argument is not a valid stream resource in /in/UjBS6 on line 8 Second lock FAIL Warning: unlink(testfile) [http://www.php.net/function.unlink]: Read-only file system in /in/UjBS6 on line 15

preferences:
232.96 ms | 404 KiB | 311 Q