3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait OverloadConstructor { public function __construct(... $args) { $length = strlen('initMethod'); foreach (get_class_methods($this) as $method) { if (substr($method, 0, $length) === 'initMethod') { $this->{$method}(... $args); } } } } trait Init1 { protected function initMethodInit1(... $args) { echo 'initMethodInit1' . PHP_EOL; } } trait Init2 { protected function initMethodInit2(... $args) { echo 'initMethodInit2' . PHP_EOL; } } class InitTest { use OverloadConstructor, Init1; protected function initMethodInitTest(... $args) { echo 'initMethodInitTest' . PHP_EOL; } } class ChangeBehaviourOfInitTest extends InitTest { use Init2; protected function initMethodChangeBehaviourOfInitTest(... $args) { echo 'initMethodChangeBehaviourOfInitTest' . PHP_EOL; } } new InitTest(); new ChangeBehaviourOfInitTest();
Output for git.master, git.master_jit, rfc.property-hooks
initMethodInitTest initMethodInit1 initMethodChangeBehaviourOfInitTest initMethodInitTest initMethodInit1 initMethodInit2

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