3v4l.org

run code in 300+ PHP versions simultaneously
<?php class cls { public static function meth(int $a, string $b) : void { throw new Exception; } public function meth2(int $a, string $b): void { throw new Exception; } } try { cls::meth(1,'hello'); }catch (\Throwable $t) { var_export($t->getTrace()); echo "\n"; } try { (new cls)->meth2(1,'hello'); }catch (\Throwable $t) { var_export($t->getTrace()); echo "\n"; } function func() { throw new Exception; } try { func(); }catch (\Throwable $t) { var_export($t->getTrace()); echo "\n"; } try{ (function() { throw new Exception;})(); } catch (\Throwable $t) { var_export($t->getTrace()); echo "\n"; } try { throw new Exception; } catch (\Throwable $t) { var_export($t->getTrace()); echo "\n"; }
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
array ( 0 => array ( 'file' => '/in/iQoni', 'line' => 17, 'function' => 'meth', 'class' => 'cls', 'type' => '::', 'args' => array ( 0 => 1, 1 => 'hello', ), ), ) array ( 0 => array ( 'file' => '/in/iQoni', 'line' => 24, 'function' => 'meth2', 'class' => 'cls', 'type' => '->', 'args' => array ( 0 => 1, 1 => 'hello', ), ), ) array ( 0 => array ( 'file' => '/in/iQoni', 'line' => 35, 'function' => 'func', 'args' => array ( ), ), ) array ( 0 => array ( 'file' => '/in/iQoni', 'line' => 42, 'function' => '{closure}', 'args' => array ( ), ), ) array ( )

preferences:
92.8 ms | 404 KiB | 123 Q