3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Hook { public function __construct( public string $hook, public string $method = '', public ?string $module = NULL, ) {} } class Alter extends Hook { public function __construct( public string $hook, public string $method = '', public ?string $module = NULL, ) { parent::__construct($hook . '_alter'); } } class FormAlter extends Alter { public function __construct( public string $hook = '', public string $method = '', public ?string $module = NULL, ) { parent::__construct($hook ? 'form_' . $hook : 'form'); } } var_dump(new Alter('foo')); var_dump(new FormAlter()); var_dump(new FormAlter('foo'));
Output for git.master, git.master_jit
object(Alter)#1 (3) { ["hook"]=> string(9) "foo_alter" ["method"]=> string(0) "" ["module"]=> NULL } object(FormAlter)#1 (3) { ["hook"]=> string(10) "form_alter" ["method"]=> string(0) "" ["module"]=> NULL } object(FormAlter)#1 (3) { ["hook"]=> string(14) "form_foo_alter" ["method"]=> string(0) "" ["module"]=> NULL }

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:
63.98 ms | 406 KiB | 5 Q