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)); var_dump($a->multiply(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/1veYm on line 35 int(5) Warning: Undefined property: A::$multiply in /in/1veYm on line 26 Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, no array or string given in /in/1veYm:26 Stack trace: #0 /in/1veYm(40): A->__call('multiply', Array) #1 {main} thrown in /in/1veYm on line 26
Process exited with code 255.

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