3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* as cuf #0 /documents/projects/github/Blog/Blog/src/test.php(25): bbq() #1 [internal function]: omg() #2 /documents/projects/github/Blog/Blog/src/test.php(6): call_user_func('omg') #3 {main} as func call #0 /documents/projects/github/Blog/Blog/src/test.php(25): bbq() #1 /documents/projects/github/Blog/Blog/src/test.php(15): omg() #2 {main} */ 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.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
as cuf #0 /in/HlQqB(39): bbq() #1 /in/HlQqB(20): omg() #2 {main} as func call #0 /in/HlQqB(39): bbq() #1 /in/HlQqB(29): 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/HlQqB(39): bbq() #1 [internal function]: omg() #2 /in/HlQqB(20): call_user_func('omg') #3 {main} as func call #0 /in/HlQqB(39): bbq() #1 /in/HlQqB(29): omg() #2 {main}

preferences:
89.63 ms | 1727 KiB | 4 Q