3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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; }
based on pVN70
Output for 7.0.0 - 7.2.0
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.3.18 - 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}