3v4l.org

run code in 300+ PHP versions simultaneously
<?php try { echo "as cuf\n"; call_user_func('omg'); } catch (\Exception $e) { echo $e->getTraceAsString(); } echo "\n\n"; try { omg(); } catch (\Exception $e) { echo "as func call\n"; echo $e->getTraceAsString(); } function omg() { bbq(); } function bbq() { throw new \Exception("testing"); } function getExceptionString(\Exception $ex) { $string = ''; while ($ex) { $string .= "Exception " . get_class($ex) . ': ' . $ex->getMessage()."\n"; foreach ($ex->getTrace() as $tracePart) { $line = false; $string .= var_export($tracePart, true); $string .= "\n"; if (isset($tracePart['file']) ) { $line .= $tracePart['file']." "; } if (isset($tracePart['line']) ) { $line .= $tracePart['line']." "; } if (isset($tracePart["class"])) { $line .= $tracePart["class"]; } if (isset($tracePart["type"])) { $line .= $tracePart["type"]; } if (isset($tracePart["function"])) { $line .= $tracePart["function"]; } if ($line === false) { $string .= "***\n"; } else { $string .= $line."\n"; } } $ex = $ex->getPrevious(); if ($ex) { $string .= "Previous "; } }; return $string; }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
as cuf #0 /in/BgGKq(25): bbq() #1 /in/BgGKq(6): omg() #2 {main} as func call #0 /in/BgGKq(25): bbq() #1 /in/BgGKq(15): omg() #2 {main}
Output for 5.4.8 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
as cuf #0 /in/BgGKq(25): bbq() #1 [internal function]: omg() #2 /in/BgGKq(6): call_user_func('omg') #3 {main} as func call #0 /in/BgGKq(25): bbq() #1 /in/BgGKq(15): omg() #2 {main}

preferences:
169.67 ms | 402 KiB | 222 Q