3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('zend.exception_ignore_args', 1); function main() { try { foo(false); } catch (Exception $ex) { echo $ex->getMessage() . PHP_EOL; } try { foo(true); } catch (Exception $ex) { echo $ex->getMessage() . PHP_EOL; } } function foo($ok) { $file = new SplFileObject('/tmp/hoge.txt', 'a'); if ($file->flock(LOCK_EX|LOCK_NB) == false) { throw new RuntimeException("Unable lock file"); } bar($file, $ok); // この関数を抜けたときにファイルは閉じられるはず } function bar(SplFileObject $file, $ok) { // なにか処理する if ($ok == false) { // 失敗したので例外を投げる throw new RuntimeException("oops!!!"); } echo "ok\n"; } main();
Output for git.master_jit, git.master, rfc.property-hooks
oops!!! ok

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
26.71 ms | 405 KiB | 5 Q