3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExecutionFailureBuilder { public function build(\Throwable $execption): ExecutionFailureInterface { } public static function flattenExceptionBacktrace(\Throwable $throwable) { $flatten = function(&$value, $key) { if ($value instanceof \Closure) { $closureReflection = new \ReflectionFunction($value); $value = sprintf( '(Closure at %s:%s)', $closureReflection->getFileName(), $closureReflection->getStartLine() ); } elseif (is_object($value)) { $value = sprintf('object(%s)', get_class($value)); } elseif (is_resource($value)) { $value = sprintf('resource(%s)', get_resource_type($value)); } }; do { $trace = $throwable->getTrace(); foreach ($trace as &$call) { array_walk_recursive($call['args'], $flatten); } var_dump($trace); } while($throwable = $throwable->getPrevious()); } } $a = function($b, string $c) { try { throw new Exception(); } catch (Exception $e) { ExecutionFailureBuilder::flattenExceptionBacktrace($e); } }; $b = new class(4, 'rfvtgb') { public function __construct($b, string $c) { try { throw new Exception(); } catch (Exception $e) { ExecutionFailureBuilder::flattenExceptionBacktrace($e); } } }; class Testing { public static function test($b, string $c) { try { throw new Exception(); } catch (Exception $e) { ExecutionFailureBuilder::flattenExceptionBacktrace($e); } } }; $a(3, 'RTYuio', new \stdClass, []); Testing::test(5, 'rfv');
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { [0]=> &array(6) { ["file"]=> string(9) "/in/6a5H4" ["line"]=> int(46) ["function"]=> string(11) "__construct" ["class"]=> string(30) "class@anonymous/in/6a5H4:46$0" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> int(4) [1]=> string(6) "rfvtgb" } } } array(1) { [0]=> &array(4) { ["file"]=> string(9) "/in/6a5H4" ["line"]=> int(69) ["function"]=> string(9) "{closure}" ["args"]=> array(4) { [0]=> int(3) [1]=> string(6) "RTYuio" [2]=> string(16) "object(stdClass)" [3]=> array(0) { } } } } array(1) { [0]=> &array(6) { ["file"]=> string(9) "/in/6a5H4" ["line"]=> int(70) ["function"]=> string(4) "test" ["class"]=> string(7) "Testing" ["type"]=> string(2) "::" ["args"]=> array(2) { [0]=> int(5) [1]=> string(3) "rfv" } } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.49 ms | 403 KiB | 8 Q