3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public $name; public $lastName; private $methods = array(); public function __construct($namae,$myozi) { $this->name = $namae; $this->lastName = $myozi; } function method() { return print "姓:".$this->lastName."名:".$this->name; } public function registerMethod($name, Closure $method) { $this->methods[$name] = $method; } public function __call($name, $arguments) { if (array_key_exists($name, $this->methods)) { $this->methods[$name](); } else { throw new BadMethodCallException('No such method: ' . $name); } } } $test = new Test("太郎","田中"); $test->registerMethod( 'aaaa', function() { print 'aaaa'; } ); $test->aaaa(); $test->bbbb();
Output for git.master, git.master_jit, rfc.property-hooks
aaaa Fatal error: Uncaught BadMethodCallException: No such method: bbbb in /in/2sdnJ:25 Stack trace: #0 /in/2sdnJ(40): Test->__call('bbbb', Array) #1 {main} thrown in /in/2sdnJ on line 25
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:
109.96 ms | 405 KiB | 5 Q