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 (debug_backtrace() as $level) { var_dump($level); } } function bar() { $this->getBacktrace(); } function baz() { Foo::getBacktrace(); } } $a = new Foo; $a->bar(); Foo::baz();
based on cSjVJ
Output for 7.0.0 - 7.1.0
array(7) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(23) ["function"]=> string(12) "getBacktrace" ["class"]=> string(3) "Foo" ["object"]=> object(Foo)#1 (0) { } ["type"]=> string(2) "->" ["args"]=> array(0) { } } array(7) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(32) ["function"]=> string(3) "bar" ["class"]=> string(3) "Foo" ["object"]=> object(Foo)#1 (0) { } ["type"]=> string(2) "->" ["args"]=> array(0) { } } Deprecated: Non-static method Foo::baz() should not be called statically in /in/Fempo on line 33 Deprecated: Non-static method Foo::getBacktrace() should not be called statically in /in/Fempo on line 27 array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(27) ["function"]=> string(12) "getBacktrace" ["class"]=> string(3) "Foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } } array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(33) ["function"]=> string(3) "baz" ["class"]=> string(3) "Foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } }
Output for 5.1.1 - 5.6.28
array(7) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(23) ["function"]=> string(12) "getBacktrace" ["class"]=> string(3) "Foo" ["object"]=> object(Foo)#1 (0) { } ["type"]=> string(2) "->" ["args"]=> array(0) { } } array(7) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(32) ["function"]=> string(3) "bar" ["class"]=> string(3) "Foo" ["object"]=> object(Foo)#1 (0) { } ["type"]=> string(2) "->" ["args"]=> array(0) { } } Strict Standards: Non-static method Foo::baz() should not be called statically in /in/Fempo on line 33 Strict Standards: Non-static method Foo::getBacktrace() should not be called statically in /in/Fempo on line 27 array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(27) ["function"]=> string(12) "getBacktrace" ["class"]=> string(3) "Foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } } array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(33) ["function"]=> string(3) "baz" ["class"]=> string(3) "Foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } }
Output for 5.0.0 - 5.1.0
array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(23) ["function"]=> string(12) "getBacktrace" ["class"]=> string(3) "Foo" ["type"]=> string(2) "->" ["args"]=> array(0) { } } array(6) { ["file"]=> string(9) "/in/Fempo" ["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/Fempo on line 33 Strict Standards: Non-static method Foo::getBacktrace() should not be called statically in /in/Fempo on line 27 array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(27) ["function"]=> string(12) "getBacktrace" ["class"]=> string(3) "Foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } } array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(33) ["function"]=> string(3) "baz" ["class"]=> string(3) "Foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } }
Output for 4.3.0 - 4.4.9
array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(23) ["function"]=> string(12) "getbacktrace" ["class"]=> string(3) "foo" ["type"]=> string(2) "->" ["args"]=> array(0) { } } array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(32) ["function"]=> string(3) "bar" ["class"]=> string(3) "foo" ["type"]=> string(2) "->" ["args"]=> array(0) { } } array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(27) ["function"]=> string(12) "getbacktrace" ["class"]=> string(3) "foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } } array(6) { ["file"]=> string(9) "/in/Fempo" ["line"]=> int(33) ["function"]=> string(3) "baz" ["class"]=> string(3) "foo" ["type"]=> string(2) "::" ["args"]=> array(0) { } }