3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.3.0 - 8.3.7
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 Fatal error: Uncaught TypeError: flock(): Argument #1 ($stream) must be of type resource, false given in /in/nS92E:8 Stack trace: #0 /in/nS92E(8): flock(false, 2) #1 {main} thrown in /in/nS92E on line 8
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
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 Fatal error: Uncaught TypeError: flock(): Argument #1 ($stream) must be of type resource, bool given in /in/nS92E:8 Stack trace: #0 /in/nS92E(8): flock(false, 2) #1 {main} thrown in /in/nS92E on line 8
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
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, bool 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, bool given in /in/nS92E on line 12 NULL
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34
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 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Warning</b>: touch() [<a href='function.touch'>function.touch</a>]: Unable to create file /in/test.lock because Permission denied in <b>/in/nS92E</b> on line <b>4</b><br /> <br /> <b>Warning</b>: fopen(/in/test.lock) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in <b>/in/nS92E</b> on line <b>6</b><br /> <br /> <b>Warning</b>: flock() expects parameter 1 to be resource, boolean given in <b>/in/nS92E</b> on line <b>8</b><br /> NULL<br /> <b>Warning</b>: fopen(/in/test.lock) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in <b>/in/nS92E</b> on line <b>10</b><br /> <br /> <b>Warning</b>: flock() expects parameter 1 to be resource, boolean given in <b>/in/nS92E</b> on line <b>12</b><br /> NULL
Output for 4.4.3 - 4.4.9
<br /> <b>Warning</b>: touch() [<a href='function.touch'>function.touch</a>]: Unable to create file /in/test.lock because Permission denied in <b>/in/nS92E</b> on line <b>4</b><br /> <br /> <b>Warning</b>: fopen(/in/test.lock) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in <b>/in/nS92E</b> on line <b>6</b><br /> <br /> <b>Warning</b>: flock(): supplied argument is not a valid stream resource in <b>/in/nS92E</b> on line <b>8</b><br /> false<br /> <b>Warning</b>: fopen(/in/test.lock) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in <b>/in/nS92E</b> on line <b>10</b><br /> <br /> <b>Warning</b>: flock(): supplied argument is not a valid stream resource in <b>/in/nS92E</b> on line <b>12</b><br /> false
Output for 4.3.5 - 4.3.11, 4.4.0 - 4.4.2
<br /> <b>Warning</b>: touch(): Unable to create file /in/test.lock because Permission denied in <b>/in/nS92E</b> on line <b>4</b><br /> <br /> <b>Warning</b>: fopen(/in/test.lock): failed to open stream: No such file or directory in <b>/in/nS92E</b> on line <b>6</b><br /> <br /> <b>Warning</b>: flock(): supplied argument is not a valid stream resource in <b>/in/nS92E</b> on line <b>8</b><br /> false<br /> <b>Warning</b>: fopen(/in/test.lock): failed to open stream: No such file or directory in <b>/in/nS92E</b> on line <b>10</b><br /> <br /> <b>Warning</b>: flock(): supplied argument is not a valid stream resource in <b>/in/nS92E</b> on line <b>12</b><br /> false
Output for 4.3.2 - 4.3.4
<br /> <b>Warning</b>: touch(): Unable to create file /in/test.lock because Permission denied in <b>/in/nS92E</b> on line <b>4</b><br /> <br /> <b>Warning</b>: fopen(/in/test.lock): failed to open stream: No such file or directory in <b>/in/nS92E</b> on line <b>6</b><br /> <br /> <b>Warning</b>: flock(): supplied argument is not a valid stream resource in <b>/in/nS92E</b> on line <b>8</b><br /> NULL<br /> <b>Warning</b>: fopen(/in/test.lock): failed to open stream: No such file or directory in <b>/in/nS92E</b> on line <b>10</b><br /> <br /> <b>Warning</b>: flock(): supplied argument is not a valid stream resource in <b>/in/nS92E</b> on line <b>12</b><br /> NULL
Output for 4.3.0 - 4.3.1
<br /> <b>Warning</b>: touch() [<a href='http://www.php.net/function.touch'>function.touch</a>]: Unable to create file /in/test.lock because Permission denied in <b>/in/nS92E</b> on line <b>4</b><br /> <br /> <b>Warning</b>: fopen(/in/test.lock) [<a href='http://www.php.net/function.fopen'>function.fopen</a>]: failed to create stream: No such file or directory in <b>/in/nS92E</b> on line <b>6</b><br /> <br /> <b>Warning</b>: flock(): supplied argument is not a valid stream resource in <b>/in/nS92E</b> on line <b>8</b><br /> NULL<br /> <b>Warning</b>: fopen(/in/test.lock) [<a href='http://www.php.net/function.fopen'>function.fopen</a>]: failed to create stream: No such file or directory in <b>/in/nS92E</b> on line <b>10</b><br /> <br /> <b>Warning</b>: flock(): supplied argument is not a valid stream resource in <b>/in/nS92E</b> on line <b>12</b><br /> NULL

preferences:
281.48 ms | 403 KiB | 469 Q