3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function callme(callable $callback) { $callback(); } public function hi() { echo 'A->hi()' . PHP_EOL; } public static function hiStatic() { echo 'A::hiStatic()' . PHP_EOL; } } class B extends A { public function callme(callable $callback) { call_user_func($callback); } public function hi() { echo 'B->hi()' . PHP_EOL; } public static function hiStatic() { echo 'B::hiStatic()' . PHP_EOL; } } $a = new A(); $b = new B(); $a->callme(array($a, 'hi')); echo "####################\n"; $a->callme(array('A', 'hiStatic')); //$a->callme('A::hiStatic'); $a->callme(array('self', 'hiStatic')); //$a->callme('self::hiStatic'); $a->callme(array('static', 'hiStatic')); $a->callme('static::hiStatic'); echo "####################\n"; $b->callme(array('B', 'hiStatic')); $b->callme(array('self', 'hiStatic')); $b->callme(array('static', 'hiStatic')); echo "####################\n"; $b->callme('B::hiStatic'); $b->callme('self::hiStatic'); $b->callme('static::hiStatic'); echo "####################\n"; $b->callme('parent::hi'); $b->callme('parent::hiStatic');
Output for git.master, git.master_jit, rfc.property-hooks
A->hi() #################### A::hiStatic() Deprecated: Use of "self" in callables is deprecated in /in/iq7m7 on line 4 Fatal error: Uncaught Error: Class "self" not found in /in/iq7m7:5 Stack trace: #0 /in/iq7m7(29): A->callme(Array) #1 {main} thrown in /in/iq7m7 on line 5
Process exited with code 255.

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:
50.04 ms | 401 KiB | 8 Q