3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php file_put_contents("testfile", "testcontent"); 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");
based on UjBS6
Output for 5.0.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: file_put_contents(testfile): failed to open stream: Permission denied in /in/PFOZu on line 2 Warning: fopen(testfile): failed to open stream: No such file or directory in /in/PFOZu on line 5 Warning: flock() expects parameter 1 to be resource, boolean given in /in/PFOZu on line 6 First lock FAIL Warning: fopen(testfile): failed to open stream: No such file or directory in /in/PFOZu on line 7 Warning: flock() expects parameter 1 to be resource, boolean given in /in/PFOZu on line 8 Second lock FAIL Function returned. Warning: fopen(testfile): failed to open stream: No such file or directory in /in/PFOZu on line 5 Warning: flock() expects parameter 1 to be resource, boolean given in /in/PFOZu on line 6 First lock FAIL Warning: fopen(testfile): failed to open stream: No such file or directory in /in/PFOZu on line 7 Warning: flock() expects parameter 1 to be resource, boolean given in /in/PFOZu on line 8 Second lock FAIL Warning: unlink(testfile): No such file or directory in /in/PFOZu on line 15
Output for hhvm-3.10.0 - 3.12.0
Warning: Permission denied in /in/PFOZu on line 2 Warning: No such file or directory in /in/PFOZu on line 5 Warning: flock() expects parameter 1 to be resource, boolean given in /in/PFOZu on line 6 First lock FAIL Warning: No such file or directory in /in/PFOZu on line 7 Warning: flock() expects parameter 1 to be resource, boolean given in /in/PFOZu on line 8 Second lock FAIL Function returned. Warning: No such file or directory in /in/PFOZu on line 5 Warning: flock() expects parameter 1 to be resource, boolean given in /in/PFOZu on line 6 First lock FAIL Warning: No such file or directory in /in/PFOZu on line 7 Warning: flock() expects parameter 1 to be resource, boolean given in /in/PFOZu on line 8 Second lock FAIL Warning: unlink(testfile): No such file or directory in /in/PFOZu on line 15
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: file_put_contents() in /in/PFOZu on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: file_put_contents() in /in/PFOZu on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: file_put_contents() in /in/PFOZu on line 2