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; }

preferences:
95.67 ms | 402 KiB | 5 Q