3v4l.org

run code in 300+ PHP versions simultaneously
<?php // A simple test object class testObj { private $id; static private $sid; public function controller(array $array) { $this->id=$array; } public function setId($newId) { $this->id = $newId; } public function staticcontroller(array $array) { self::$sid=$array; } } class testFacade { function driver() { return "testObj"; } public static function __callStatic($method, $parameters) { return call_user_func_array(array(static::driver(), $method), $parameters); } } $params=array("a"=>1,"b"=>2,"c"=>3,"p"=>$_GET["m"]); $method=$_GET["m"]; for($i=0;$i<10;$i++) switch ($method) { case "variable": $a = "testObj"; $method = "setId"; $test1 = new $a; $test1->$method($_GET["m"]); $method = "controller"; $test1->$method($params); break; case "reflexion": $a = "testObj"; $method = "setId"; $reflectionClass = new ReflectionClass($a); $test2 = $reflectionClass->newInstance(); $reflectionMethod = $reflectionClass->getMethod($method); $reflectionMethod->invoke($test2,33); $method = "controller"; $reflectionMethod = $reflectionClass->getMethod($method); $reflectionMethod->invoke($test2,$params); break; case "call_user_func_array": $a = "testObj"; $test1 = new $a; $method = "setId"; $r=call_user_func_array(array($test1, $method), array(1)); $method = "controller"; $r=call_user_func_array(array($test1, $method), array( $params)); break; case "static1": testObj::staticcontroller($params); break; case "static2": $a = "testObj"; $method = "staticcontroller"; $a::$method($params); break; case "static3": testFacade::staticcontroller( $params); break; }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key "m" in /in/Kb2F0 on line 42 Warning: Undefined array key "m" in /in/Kb2F0 on line 43

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