3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $a = new stdClass(); // $a->sum = function($a,$b){return $a + $b;}; // // var_dump($a->sum); // // echo ($a->sum)(3,5); // $b = (object)["sum" => function($a,$b){return $a + $b;}]; // var_dump(($b->sum)(1,2)); class A{ public $sum; function __construct(){ $this->sum = function($a, $b){ return $a + $b; }; } function __call($method,$args) { // var_dump($method,$args); return call_user_func_array($this->$method, $args); // var_dump($test,$this->$method); } } $a = new A(); var_dump($a->sum(1,2)); $a->sub = function($a, $b){ return $a- $b; }; var_dump($a->sub(10,5));
Output for git.master, git.master_jit, rfc.property-hooks
int(3) Deprecated: Creation of dynamic property A::$sub is deprecated in /in/lGPEU on line 35 int(5)

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