3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Lock { function __destruct() { echo "***lock released now***\n"; } } class LockedFile { private $lock; function __construct(string $path) { $this->lock = new Lock(); } } class LineReader { function __construct(private LockedFile $file) {} function readLines() { } } function process_lines(LineReader $reader) { throw new Exception("readLines"); } function process_file(string $path): string { try { $file = new LockedFile($path); $reader = new LineReader($file); process_lines($reader); } catch (Exception $e) { // release file echo "unsetting \$file, \$reader...\n"; unset($file, $reader); // $file is still referenced via $e->getTrace()[0]['args'][0]->file throw new Exception('Processing failed', previous: $e); } return $content; } process_file('/some/file.txt');
Output for git.master_jit, git.master
unsetting $file, $reader... Fatal error: Uncaught Exception: readLines in /in/lsicN:23 Stack trace: #0 /in/lsicN(30): process_lines(Object(LineReader)) #1 /in/lsicN(44): process_file('/some/file.txt') #2 {main} Next Exception: Processing failed in /in/lsicN:38 Stack trace: #0 /in/lsicN(44): process_file('/some/file.txt') #1 {main} thrown in /in/lsicN on line 38 ***lock released now***
Process exited with code 255.

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:
35.12 ms | 406 KiB | 5 Q