3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php if (!defined('PHP_INT_MAX')) { $min = -1; do { $last = $min; } while(0 > $min <<= 1); define('PHP_INT_MIN', $last); define('PHP_INT_MAX', ~$last); } class Foo { function getBacktrace($firstLevel = 0, $count = PHP_INT_MAX) { $result = array(); foreach (array_slice(debug_backtrace(false), 1 + $firstLevel) as $level) { var_dump($level); } } function bar() { $this->getBacktrace(); } function baz() { Foo::getBacktrace(); } } $a = new Foo; $a->bar(); Foo::baz();
based on rrkOA
Output for 7.0.0 - 7.1.0
array(6) { ["file"]=> string(9) "/in/r82We" ["line"]=> int(32) ["function"]=> string(3) "bar" ["class"]=> string(3) "Foo" ["type"]=> string(2) "->" ["args"]=> array(0) { } } Deprecated: Non-static method Foo::baz() should not be called statically in /in/r82We on line 33 Deprecated: Non-static method Foo::getBacktrace() should not be called statically in /in/r82We on line 27 array(6) { ["file"]=> string(9) "/in/r82We" ["line"]=> int(33) ["function"]=> string(3) "baz" ["class"]=> string(3) "Foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } }
Output for hhvm-3.10.0 - 3.12.0
array(6) { ["file"]=> string(9) "/in/r82We" ["line"]=> int(32) ["function"]=> string(3) "bar" ["class"]=> string(3) "Foo" ["type"]=> string(2) "->" ["args"]=> array(0) { } } array(6) { ["file"]=> string(9) "/in/r82We" ["line"]=> int(33) ["function"]=> string(3) "baz" ["class"]=> string(3) "Foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } }
Output for 5.2.5 - 5.6.28
array(6) { ["file"]=> string(9) "/in/r82We" ["line"]=> int(32) ["function"]=> string(3) "bar" ["class"]=> string(3) "Foo" ["type"]=> string(2) "->" ["args"]=> array(0) { } } Strict Standards: Non-static method Foo::baz() should not be called statically in /in/r82We on line 33 Strict Standards: Non-static method Foo::getBacktrace() should not be called statically in /in/r82We on line 27 array(6) { ["file"]=> string(9) "/in/r82We" ["line"]=> int(33) ["function"]=> string(3) "baz" ["class"]=> string(3) "Foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } }
Output for 5.0.0 - 5.2.4
Warning: Wrong parameter count for debug_backtrace() in /in/r82We on line 17 Warning: array_slice(): The first argument should be an array in /in/r82We on line 17 Warning: Invalid argument supplied for foreach() in /in/r82We on line 17 Strict Standards: Non-static method Foo::baz() should not be called statically in /in/r82We on line 33 Strict Standards: Non-static method Foo::getBacktrace() should not be called statically in /in/r82We on line 27 Warning: Wrong parameter count for debug_backtrace() in /in/r82We on line 17 Warning: array_slice(): The first argument should be an array in /in/r82We on line 17 Warning: Invalid argument supplied for foreach() in /in/r82We on line 17
Output for 4.3.2 - 4.3.10, 4.4.0 - 4.4.9
Warning: Wrong parameter count for debug_backtrace() in /in/r82We on line 17 Warning: array_slice(): The first argument should be an array in /in/r82We on line 17 Warning: Invalid argument supplied for foreach() in /in/r82We on line 17 Warning: Wrong parameter count for debug_backtrace() in /in/r82We on line 17 Warning: array_slice(): The first argument should be an array in /in/r82We on line 17 Warning: Invalid argument supplied for foreach() in /in/r82We on line 17
Output for 4.3.11
Warning: Wrong parameter count for debug_backtrace() in /in/r82We on line 17 Warning: array_slice(): The first argument should be an array in /in/r82We on line 17 Warning: Wrong parameter count for debug_backtrace() in /in/r82We on line 17 Warning: array_slice(): The first argument should be an array in /in/r82We on line 17
Output for 4.3.0 - 4.3.1
Warning: Wrong parameter count for debug_backtrace() in /in/r82We on line 17 Warning: array_slice() [http://www.php.net/function.array-slice]: The first argument should be an array in /in/r82We on line 17 Warning: Invalid argument supplied for foreach() in /in/r82We on line 17 Warning: Wrong parameter count for debug_backtrace() in /in/r82We on line 17 Warning: array_slice() [http://www.php.net/function.array-slice]: The first argument should be an array in /in/r82We on line 17 Warning: Invalid argument supplied for foreach() in /in/r82We on line 17