3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[NoDiscard] function lockFile(string $path) { $handle = fopen($path, 'r+'); if (! $handle || ! flock($handle, LOCK_EX)) { throw new RuntimeException('Failed locking ' . $path); } return $handle; } // what we write function main() { lockFile($path); doSomething(); echo 'hi'; } // gets rewritten internally to something like function main() { $hidden = lockFile($path); doSomething(); echo 'hi'; unset($hidden); } // if we do assign it, we omit it all // what we write here would not get rewritten function main() { $handle = lockFile($path); doSomething(); echo 'hi'; } // if we were to ever get a "using"-like // what we write function main() { using { lockFile($path); doSomething(); } echo 'hi'; } // gets rewritten internally to something like function main() { $hidden = lockFile($path); doSomething(); unset($hidden); echo 'hi'; }
Output for 8.4.1 - 8.4.4
Parse error: syntax error, unexpected token "{" in /in/L4bOc on line 38
Process exited with code 255.
Output for 8.2.0 - 8.2.27, 8.3.0 - 8.3.17
Parse error: syntax error, unexpected token ";" in /in/L4bOc on line 39
Process exited with code 255.

preferences:
159.78 ms | 1001 KiB | 7 Q