3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php file_put_contents("/tmp/testfile", "testcontent"); function mylock() { $F1 = fopen("/tmp/testfile","r"); if (flock($F1,LOCK_EX|LOCK_NB)) echo "First lock OK\n"; else echo "First lock FAIL\n"; $F2 = fopen("/tmp/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("/tmp/testfile");
based on PFOZu
Output for 5.0.5 - 7.1.0
First lock OK Second lock FAIL Function returned. First lock OK Second lock FAIL
Output for 5.0.0 - 5.0.4
First lock OK Second lock OK Function returned. First lock OK Second lock OK
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: file_put_contents() in /in/qOT1t 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/qOT1t 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/qOT1t on line 2