3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_cc() { $calls = debug_backtrace(); if (!isset($calls[1])) { return NULL; } $call = $calls[1]; var_dump($call); if (isset($call['object'])) { return get_class($call['object']); } elseif (isset($call['class'])) { return $call['class']; } } class Bar { public function bar() { return get_cc(); } public static function baz() { return get_cc(); } } class Foo extends Bar { } $bar = new Bar; echo ($bar->bar() === 'Bar' ? 'OK' : 'FAIL'), "\n<br>"; echo (Bar::baz() === 'Bar' ? 'OK' : 'FAIL'), "\n<br>"; $foo = new Foo; echo ($foo->bar() === 'Foo' ? 'OK' : 'FAIL'), "\n<br>"; echo (Foo::baz() === 'Foo' ? 'OK' : 'FAIL'), "\n<br>"; echo (get_cc() === NULL ? 'OK' : 'FAIL'), "\n<br>";
Output for git.master, git.master_jit, rfc.property-hooks
array(7) { ["file"]=> string(9) "/in/ZMHDn" ["line"]=> int(44) ["function"]=> string(3) "bar" ["class"]=> string(3) "Bar" ["object"]=> object(Bar)#1 (0) { } ["type"]=> string(2) "->" ["args"]=> array(0) { } } OK <br>array(6) { ["file"]=> string(9) "/in/ZMHDn" ["line"]=> int(45) ["function"]=> string(3) "baz" ["class"]=> string(3) "Bar" ["type"]=> string(2) "::" ["args"]=> array(0) { } } OK <br>array(7) { ["file"]=> string(9) "/in/ZMHDn" ["line"]=> int(48) ["function"]=> string(3) "bar" ["class"]=> string(3) "Bar" ["object"]=> object(Foo)#2 (0) { } ["type"]=> string(2) "->" ["args"]=> array(0) { } } OK <br>array(6) { ["file"]=> string(9) "/in/ZMHDn" ["line"]=> int(49) ["function"]=> string(3) "baz" ["class"]=> string(3) "Bar" ["type"]=> string(2) "::" ["args"]=> array(0) { } } FAIL <br>OK <br>

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:
51.59 ms | 403 KiB | 8 Q