3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dump(...$values): void { foreach ($values as $value) { echo json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL; } } class Foo { public readonly Exception $e; public function __construct() { $this->e = new Exception; dump(debug_backtrace()); } } class Bar extends Foo { public function __construct() { parent::__construct(); } } function Bar(): Bar { return new Bar(); } $bar = new Bar(); dump($bar->e->getTrace());
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.5 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
[ { "file": "/in/QjBWV", "line": 24, "function": "__construct", "class": "Foo", "object": { "e": {} }, "type": "->", "args": [] }, { "file": "/in/QjBWV", "line": 33, "function": "__construct", "class": "Bar", "object": { "e": {} }, "type": "->", "args": [] } ] [ { "file": "/in/QjBWV", "line": 24, "function": "__construct", "class": "Foo", "type": "->", "args": [] }, { "file": "/in/QjBWV", "line": 33, "function": "__construct", "class": "Bar", "type": "->", "args": [] } ]
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.0.1 - 8.0.28
Parse error: syntax error, unexpected identifier "Exception", expecting variable in /in/QjBWV on line 12
Process exited with code 255.

preferences:
90.29 ms | 409 KiB | 5 Q