3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @see: https://stackoverflow.com/a/47374090/2377961 */ class Hook { protected static $hooks = array(); public function __construct() { return new __Hook(); } public static function on($event, $fn) { self::$hooks[$event][] = $fn; echo "Static click\n"; } } // Hidden class class __Hook { protected $hooks = array(); public function on($event, $fn) { $this->hooks[$event][] = $fn; echo "Non Static click\n"; } } # To call it statically: Hook::on("click", function() {}); # To call it dynamically: $hook = new Hook; $hook->on("click", function() {});
Output for git.master, git.master_jit, rfc.property-hooks
Static click Static click

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:
127.72 ms | 405 KiB | 5 Q