3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Illustrating PHP Function parameters. */ class o { private $v = 0; public function inc() { $this->v++; } public function getV() { return $this->v; } } function testParams(o $obj) { for ($x=0; $x < 10; $x++) { $obj->inc(); } return $obj->getV(); } function testParams2($fp, $text) { $text = "1." . $text . PHP_EOL; fwrite($fp, $text); } // Pass Array by Reference function testParams3(Array &$globArray) { array_push($globArray, 'grape'); } // Globally scoped variables $globArray = ['apple', 'banana', 'peach']; $obj = new o(); $r = fopen("/tmp/resource.txt", "w+"); $text = "This is some text."; // $retVal = testParams($obj); echo $retVal . PHP_EOL; echo $obj->getV() . PHP_EOL; echo PHP_EOL; echo "text before testParams2: \n"; echo "\t$text" . PHP_EOL; testParams2($r, $text); rewind($r); $fileData = fgets($r, 4096); echo "File Data:\n"; echo "\t$fileData"; echo "text After testParams2::\n"; echo "\t$text" . PHP_EOL; echo PHP_EOL; echo "Array Before testParams3:\n"; var_dump($globArray); echo PHP_EOL; testParams3($globArray); echo "Array After testParams3:\n"; var_dump($globArray);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.120.0100.01120.61
8.4.110.0440.01017.88
8.4.100.0460.01117.40
8.4.90.0460.00517.58
8.4.80.0430.00817.80
8.4.70.0390.00917.70
8.4.60.0260.00418.02
8.4.50.0150.00717.85
8.4.40.0310.00417.30
8.4.30.0380.01517.49
8.4.20.0390.01217.75
8.4.10.0210.00517.40
8.3.250.0090.01017.39
8.3.240.0110.00717.27
8.3.230.0180.00416.78
8.3.220.0200.00216.54
8.3.210.0290.00916.53
8.3.200.0280.00216.65
8.3.190.0180.00416.91
8.3.180.0290.00416.69
8.3.170.0360.01516.73
8.3.160.0400.01116.37
8.3.150.0430.00816.47
8.3.140.0430.00916.40
8.3.130.0320.00816.48
8.3.120.0390.00516.43
8.3.110.0340.01216.32
8.3.100.0400.01116.45
8.3.90.0410.01016.64
8.3.80.0420.00816.51
8.3.70.0450.00716.63
8.3.60.0420.01116.37
8.3.50.0470.00116.59
8.3.40.0380.01017.32
8.3.30.0330.01017.55
8.3.20.0330.00617.66
8.3.10.0200.00417.52
8.3.00.0360.01117.61
8.2.290.0300.00716.57
8.2.280.0280.00916.95
8.2.270.0170.00516.93
8.2.260.0230.00716.36
8.2.250.0310.00616.39
8.2.240.0160.00316.46
8.2.230.0350.00616.38
8.2.220.0300.00316.33
8.2.210.0220.00616.74
8.2.200.0300.00816.66
8.2.190.0330.00516.21
8.2.180.0350.00716.59
8.2.170.0370.01017.72
8.2.160.0380.01017.33
8.2.150.0440.00517.55
8.2.140.0390.00717.50
8.2.130.0400.00517.19
8.2.120.0400.00717.65
8.2.110.0390.00717.72
8.2.100.0410.00517.73
8.2.90.0270.00817.72
8.2.80.0360.00917.41
8.2.70.0390.00617.47
8.2.60.0380.00817.50
8.2.50.0210.00617.59
8.2.40.0430.00817.42
8.2.30.0410.00617.30
8.2.20.0320.00817.51
8.2.10.0190.00617.62
8.2.00.0360.00817.32

preferences:
24.83 ms | 403 KiB | 5 Q