3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public function testIsCallable(callable $param) { return is_callable($param); } private function privateMethod() { echo "This is a private method"; } public function test($param) { if ($this->testIsCallable($param)) { $param(); } } } class B extends A { public function test($param) { if ($this->testIsCallable($param)) { $param(); } } } $a = new A(); $b = new B(); $callable = [$a, 'privateMethod']; $a->test($callable); $b->test($callable);
based on pOu8c
Output for 7.0.0 - 7.2.0
This is a private method Fatal error: Uncaught Error: Call to private method A::privateMethod() from context 'B' in /in/qlsrm:24 Stack trace: #0 /in/qlsrm(35): B->test(Array) #1 {main} thrown in /in/qlsrm on line 24
Process exited with code 255.
Output for 5.4.2 - 5.6.28
This is a private method Fatal error: Call to private method A::privateMethod() from context 'B' in /in/qlsrm on line 24
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/qlsrm on line 32
Process exited with code 255.