3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface MakeMeCMS_Listener_interface { public function __construct($method, $args); public function setFeedback($arg, $type); public function feedback(); } class MakeMeCMS_Listener implements MakeMeCMS_Listener_interface { private $_feedback; private $_type; public function __construct($method, $args) { if(method_exists($this, $method)) { if($args != '') { if(preg_match('#\,#', $args)) { $args = explode(',', $args); } $this->$method($args); } else { $this->$method(); } } } public function setFeedback($arg,$type) { $this->_feedback = $arg; $this->_type = $type; } public function feedback() { return $this->_feedback; } private function test(array $args) { $string = ''; foreach($args as $arg) { $string .= $arg.' '; } $this->setFeedback($string, 'text/plain'); } } class myAddon_Listener extends MakeMeCMS_Listener implements MakeMeCMS_Listener_interface { public function __construct($method, $args) { if(method_exists($this, $method)) { if($args != '') { if(preg_match('#\,#', $args)) { $args = explode(',', $args); } $this->$method($args); } else { $this->$method(); } } } public function setFeedback($arg, $type) { parent::setFeedback($arg, $type); } public function feedback() { return parent::_feedback; } private function test2() { echo('Hello World!'); } } $listener = new MakeMeCMS_Listener('test', 'foo,bar'); echo($listener->feedback()); $customListener = new myAddon_Listener('test2'); echo($customListener->feedback());
based on VHRoK
Output for 7.1.0 - 7.2.0
foo bar Fatal error: Uncaught ArgumentCountError: Too few arguments to function myAddon_Listener::__construct(), 1 passed in /in/h0obG on line 64 and exactly 2 expected in /in/h0obG:39 Stack trace: #0 /in/h0obG(64): myAddon_Listener->__construct('test2') #1 {main} thrown in /in/h0obG on line 39
Process exited with code 255.
Output for 7.0.0 - 7.0.20
foo bar Warning: Missing argument 2 for myAddon_Listener::__construct(), called in /in/h0obG on line 64 and defined in /in/h0obG on line 39 Notice: Undefined variable: args in /in/h0obG on line 41 Hello World! Fatal error: Uncaught Error: Undefined class constant '_feedback' in /in/h0obG:56 Stack trace: #0 /in/h0obG(65): myAddon_Listener->feedback() #1 {main} thrown in /in/h0obG on line 56
Process exited with code 255.
Output for 5.3.19 - 5.6.28
foo bar Warning: Missing argument 2 for myAddon_Listener::__construct(), called in /in/h0obG on line 64 and defined in /in/h0obG on line 39 Notice: Undefined variable: args in /in/h0obG on line 41 Hello World! Fatal error: Undefined class constant '_feedback' in /in/h0obG on line 56
Process exited with code 255.