3v4l.org

run code in 300+ PHP versions simultaneously
<?php function e($o){return json_decode(preg_replace('/\\\u0000[*a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\\u0000/','',json_encode((array)$o)),1);} function cast($destination, $sourceObject) { if (is_string($destination)) { $destination = new $destination(); } $sourceReflection = new ReflectionObject($sourceObject); $destinationReflection = new ReflectionObject($destination); $sourceProperties = $sourceReflection->getProperties(); foreach ($sourceProperties as $sourceProperty) { $sourceProperty->setAccessible(true); $name = $sourceProperty->getName(); $value = $sourceProperty->getValue($sourceObject); if ($destinationReflection->hasProperty($name)) { $propDest = $destinationReflection->getProperty($name); $propDest->setAccessible(true); $propDest->setValue($destination,$value); } else { $destination->$name = $value; } } return $destination; } class Foo { public function test() { echo 'test'; } } function changeMe(&$obj) { $destClass = get_class($obj); //$obj = function(){ // echo 'hello'; //}; //$reflectionClass = new ReflectionClass($obj); //var_dump($reflectionClass); $obj = (array) $obj; $obj['test'] = function(){echo 'hi';}; $obj = (object) $obj; //$closure = function(){}; //$obj = cast($closure, $obj); var_dump($obj); //$out = json_encode($arr); //$out = preg_replace('/\\\u0000[*a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\\u0000/', '', $out); //echo $out . PHP_EOL; //$newArray = json_decode($out, true); //var_dump($arr, $newArray); } $foo = new Foo(); changeMe($foo); $foo->test();

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.3.60.0100.01018.43
8.3.50.0110.00521.21
8.3.40.0140.00018.80
8.3.30.0040.01819.08
8.3.20.0040.00420.34
8.3.10.0040.00422.13
8.3.00.0040.00422.39
8.2.180.0120.00317.00
8.2.170.0100.01022.96
8.2.160.0140.00719.10
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0130.00626.16
8.2.120.0040.00419.68
8.2.110.0090.00022.09
8.2.100.0080.00419.40
8.2.90.0040.00419.39
8.2.80.0040.00418.05
8.2.70.0030.00617.75
8.2.60.0000.00817.93
8.2.50.0080.00018.07
8.2.40.0120.00018.28
8.2.30.0000.00818.17
8.2.20.0050.00217.82
8.2.10.0030.00617.96
8.2.00.0030.00617.75
8.1.280.0070.00725.92
8.1.270.0050.00322.04
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00623.88
8.1.230.0080.00319.04
8.1.220.0000.00917.79
8.1.210.0030.00618.77
8.1.200.0030.00617.35
8.1.190.0040.00417.52
8.1.180.0080.00020.65
8.1.170.0050.00318.32
8.1.160.0000.00722.10
8.1.150.0070.00018.66
8.1.140.0040.00417.49
8.1.130.0030.00317.85
8.1.120.0000.00717.48
8.1.110.0040.00417.40
8.1.100.0000.00817.38
8.1.90.0040.00417.45
8.1.80.0000.00817.49
8.1.70.0070.00017.53
8.1.60.0040.00417.61
8.1.50.0060.00317.57
8.1.40.0040.00417.54
8.1.30.0000.00717.63
8.1.20.0050.00317.57
8.1.10.0050.00217.58
8.1.00.0040.00417.48
8.0.300.0050.00218.77
8.0.290.0050.00216.93
8.0.280.0030.00318.43
8.0.270.0040.00417.20
8.0.260.0000.00618.30
8.0.250.0040.00417.02
8.0.240.0040.00416.96
8.0.230.0040.00417.05
8.0.220.0000.00716.91
8.0.210.0040.00416.98
8.0.200.0070.00017.06
8.0.190.0000.00917.08
8.0.180.0040.00417.00
8.0.170.0070.00017.05
8.0.160.0050.00216.88
8.0.150.0030.00617.06
8.0.140.0030.00616.94
8.0.130.0000.00613.33
8.0.120.0040.00416.96
8.0.110.0040.00417.04
8.0.100.0000.00716.87
8.0.90.0000.00816.88
8.0.80.0060.00916.88
8.0.70.0040.00416.83
8.0.60.0050.00317.06
8.0.50.0040.00417.06
8.0.30.0090.01316.96
8.0.20.0120.00617.40
8.0.10.0040.00417.16
8.0.00.0110.01016.56
7.4.330.0000.00515.04
7.4.320.0050.00216.63
7.4.300.0060.00016.55
7.4.290.0030.00316.55
7.4.280.0070.00016.44
7.4.270.0020.00516.56
7.4.260.0030.00516.66
7.4.250.0040.00416.41
7.4.240.0050.00216.68
7.4.230.0030.00316.62
7.4.220.0080.00716.71
7.4.210.0100.00516.67
7.4.200.0040.00416.66
7.4.190.0060.00316.59
7.4.160.0130.00316.29
7.4.150.0070.01017.40
7.4.140.0080.01217.86
7.4.130.0100.00916.50
7.4.120.0030.01416.61
7.4.110.0100.01016.60
7.4.100.0110.01116.62
7.4.90.0070.01116.41
7.4.80.0030.00419.39
7.4.70.0090.00616.59
7.4.60.0070.01116.62
7.4.50.0000.00616.57
7.4.40.0080.00822.77
7.4.30.0070.01016.77
7.4.00.0030.01314.87
7.3.330.0000.00613.26
7.3.320.0020.00313.23
7.3.310.0000.00716.46
7.3.300.0000.00716.39
7.3.290.0130.00316.34
7.3.280.0120.00416.40
7.3.270.0150.00317.40
7.3.260.0070.01016.43
7.3.250.0110.00516.55
7.3.240.0090.00916.31
7.3.230.0090.00916.40
7.3.210.0070.01116.62
7.3.200.0120.01219.39
7.3.190.0140.00916.65
7.3.180.0040.01216.42
7.3.170.0110.00816.43
7.3.160.0150.00016.51
7.3.120.0090.00614.98
7.2.330.0120.00616.63
7.2.320.0090.01316.89
7.2.310.0080.00816.55
7.2.300.0050.01416.71
7.2.290.0100.00616.52
7.2.60.0100.00616.78
7.2.00.0090.00619.23
7.1.200.0060.00615.50
7.1.100.0040.01117.95
7.1.70.0100.00616.90
7.1.60.0070.01819.82
7.1.50.0080.01516.63
7.1.00.0070.03022.29
7.0.200.0040.00416.70
7.0.140.0000.08022.12
7.0.90.0500.04019.94
7.0.80.0630.07719.87
7.0.70.0570.08020.02
7.0.60.0400.04319.86
7.0.50.0600.07020.36
7.0.40.0100.04720.10
7.0.30.0170.07720.12
7.0.20.0100.08720.08
7.0.10.0130.06720.18
7.0.00.0070.08020.03
5.6.280.0000.07720.91
5.6.240.0070.05320.56
5.6.230.0100.05320.64
5.6.220.0100.07720.45
5.6.210.0030.04320.55
5.6.200.0130.04020.95
5.6.190.0170.05321.04
5.6.180.0130.06321.09
5.6.170.0130.05321.04
5.6.160.0070.06321.10
5.6.150.0100.03721.04
5.6.140.0070.08021.00
5.6.130.0100.07721.07
5.6.120.0100.08321.02
5.6.110.0030.09020.97
5.6.100.0100.07721.02
5.6.90.0070.04720.92
5.6.80.0100.07320.50
5.6.70.0100.03720.43
5.6.60.0100.06320.42
5.6.50.0100.05720.53
5.6.40.0030.04720.48
5.6.30.0170.06020.39
5.6.20.0100.07320.31
5.6.10.0170.07320.50
5.6.00.0000.05020.31
5.5.380.0130.07720.31
5.5.370.0030.08320.32
5.5.360.0000.05020.40
5.5.350.0070.04320.38
5.5.340.0170.07320.91
5.5.330.0030.08020.81
5.5.320.0170.07720.94
5.5.310.0070.06320.83
5.5.300.0030.04720.77
5.5.290.0130.05320.80
5.5.280.0030.05020.90
5.5.270.0070.06320.88
5.5.260.0100.08020.92
5.5.250.0100.04020.62
5.5.240.0070.07320.17
5.5.230.0170.05320.26
5.5.220.0130.07020.18
5.5.210.0070.06320.32
5.5.200.0100.06320.23
5.5.190.0170.03720.14
5.5.180.0030.05320.27
5.5.160.0130.06720.14
5.5.150.0070.04720.25
5.5.140.0170.06720.14
5.5.130.0100.07720.13
5.5.120.0070.07720.28
5.5.110.0070.08020.13
5.5.100.0070.08020.18
5.5.90.0030.08320.08
5.5.80.0030.05020.10
5.5.70.0100.08319.98
5.5.60.0070.07320.05
5.5.50.0130.04720.11
5.5.40.0170.06320.02
5.5.30.0130.07720.13
5.5.20.0100.04319.94
5.5.10.0070.08020.15
5.5.00.0100.06320.12
5.4.450.0000.08019.36
5.4.440.0130.07319.35
5.4.430.0030.07719.45
5.4.420.0030.04719.52
5.4.410.0100.06719.10
5.4.400.0130.03318.90
5.4.390.0100.07019.24
5.4.380.0130.07019.22
5.4.370.0030.04319.07
5.4.360.0100.07718.84
5.4.350.0070.04719.04
5.4.340.0100.06019.13
5.4.320.0070.04318.87
5.4.310.0100.05719.05
5.4.300.0000.08319.04
5.4.290.0100.07019.02
5.4.280.0000.05719.08
5.4.270.0070.07319.02
5.4.260.0030.05718.87
5.4.250.0100.06719.17
5.4.240.0100.06719.00
5.4.230.0170.06319.22
5.4.220.0030.07718.86
5.4.210.0100.07719.13
5.4.200.0130.07718.89
5.4.190.0130.06719.11
5.4.180.0070.04719.23
5.4.170.0070.07319.04
5.4.160.0130.07018.85
5.4.150.0130.07319.14
5.4.140.0130.05016.46
5.4.130.0100.07016.43
5.4.120.0070.07716.46
5.4.110.0070.05016.44
5.4.100.0070.05016.44
5.4.90.0130.05016.55
5.4.80.0030.05716.45
5.4.70.0070.06016.39
5.4.60.0100.04016.36
5.4.50.0000.04016.36
5.4.40.0070.03316.49
5.4.30.0100.03016.47
5.4.20.0030.03716.38
5.4.10.0100.03016.34
5.4.00.0030.03315.86
5.3.290.0030.08014.82
5.3.280.0170.07014.72
5.3.270.0100.08014.63
5.3.260.0100.04014.72
5.3.250.0070.03714.72
5.3.240.0070.08014.63
5.3.230.0000.07014.70
5.3.220.0000.05314.55
5.3.210.0000.07714.70
5.3.200.0000.04314.64
5.3.190.0100.07314.62
5.3.180.0130.07014.59
5.3.170.0070.03314.61
5.3.160.0000.04014.61
5.3.150.0030.04314.60
5.3.140.0070.03314.56
5.3.130.0100.03714.63
5.3.120.0070.03714.68
5.3.110.0070.03714.53
5.3.100.0130.02713.97
5.3.90.0000.04013.96
5.3.80.0030.03014.02
5.3.70.0030.03714.17
5.3.60.0030.03714.02
5.3.50.0030.03713.95
5.3.40.0070.03714.02
5.3.30.0030.03714.06
5.3.20.0000.03713.59
5.3.10.0000.03713.80
5.3.00.0030.03313.79
5.2.170.0030.02711.08
5.2.160.0030.02711.27
5.2.150.0000.02711.20
5.2.140.0070.02711.05
5.2.130.0030.04011.20
5.2.120.0070.02711.20
5.2.110.0000.03711.19
5.2.100.0030.02711.16
5.2.90.0030.02711.16
5.2.80.0030.05711.22
5.2.70.0030.04011.13
5.2.60.0070.02310.97
5.2.50.0000.02711.06
5.2.40.0000.02710.93
5.2.30.0030.02710.88
5.2.20.0000.03010.97
5.2.10.0000.03010.99
5.2.00.0000.03710.87
5.1.60.0030.02310.01
5.1.50.0000.02710.04
5.1.40.0070.03310.11
5.1.30.0000.02710.28
5.1.20.0030.02310.35
5.1.10.0000.0279.93
5.1.00.0030.0309.97
5.0.50.0000.0238.63
5.0.40.0000.0208.54
5.0.30.0030.0278.33
5.0.20.0070.0338.11
5.0.10.0030.0238.31
5.0.00.0030.0678.07
4.4.90.0000.0336.02
4.4.80.0030.0136.02
4.4.70.0000.0176.02
4.4.60.0000.0336.02
4.4.50.0000.0236.02
4.4.40.0000.0276.02
4.4.30.0030.0136.02
4.4.20.0000.0176.02
4.4.10.0030.0136.02
4.4.00.0000.0306.02
4.3.110.0000.0206.02
4.3.100.0000.0176.02
4.3.90.0070.0236.02
4.3.80.0000.0376.02
4.3.70.0000.0176.02
4.3.60.0000.0176.02
4.3.50.0030.0136.02
4.3.40.0000.0236.02
4.3.30.0000.0136.02
4.3.20.0000.0136.02
4.3.10.0030.0136.02
4.3.00.0000.0136.02

preferences:
38.31 ms | 401 KiB | 5 Q