3v4l.org

run code in 300+ PHP versions simultaneously
<?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();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
array(6) { ["file"]=> string(9) "/in/r82We" ["line"]=> int(32) ["function"]=> string(3) "bar" ["class"]=> string(3) "Foo" ["type"]=> string(2) "->" ["args"]=> array(0) { } } Fatal error: Uncaught Error: Non-static method Foo::baz() cannot be called statically in /in/r82We:33 Stack trace: #0 {main} thrown in /in/r82We on line 33
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
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 7.3.32 - 7.3.33
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.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
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.0.5, 5.1.0 - 5.1.6, 5.2.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

preferences:
274.12 ms | 402 KiB | 455 Q