3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Simple math class class Math { function __construct($a) { $this->a =$a; } //Returns a closure function mul() { //We can't directly use $this inside closure $self = $this; return function($n) use($self) { return $n*$self->a; }; } } $math = new Math(5); $mul = $math->mul(); echo $mul(4); //Output : 20 ?>
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property Math::$a is deprecated in /in/U0rKg on line 6 20

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