3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class BaseFoo { } class Foo extends BaseFoo { protected function greet($subject) { echo "Hello $subject!"; } public function callStatic($className, $methodName) { $parameters = func_get_args(); $parameters = array_slice($parameters, 2); // Remove $className and $methodName return call_user_func_array($className . '::' . $methodName, $parameters); } } class Bar extends Foo { public function publicGreet($subject) { $this->callStatic(parent, 'greet', $subject); } } $b = new Bar(); $b->publicGreet('World');
based on dSW76
Output for 7.2.0
Warning: Use of undefined constant parent - assumed 'parent' (this will throw an Error in a future version of PHP) in /in/3oJBM on line 19 Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'BaseFoo' does not have a method 'greet' in /in/3oJBM on line 12
Output for 5.3.20 - 7.1.10
Notice: Use of undefined constant parent - assumed 'parent' in /in/3oJBM on line 19 Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'BaseFoo' does not have a method 'greet' in /in/3oJBM on line 12