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['bar'] = 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.40.0070.01118.79
8.3.30.0070.00719.21
8.3.20.0040.00420.34
8.3.10.0000.00821.92
8.3.00.0040.00422.58
8.2.170.0140.00722.96
8.2.160.0090.00619.33
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0180.00026.16
8.2.120.0060.00319.66
8.2.110.0060.00321.06
8.2.100.0120.00017.93
8.2.90.0050.00319.29
8.2.80.0000.00817.97
8.2.70.0030.00617.75
8.2.60.0040.00418.05
8.2.50.0050.00318.07
8.2.40.0050.00518.32
8.2.30.0030.00618.04
8.2.20.0030.00717.93
8.2.10.0060.00317.85
8.2.00.0000.01217.91
8.1.270.0050.00322.06
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00020.86
8.1.230.0080.00317.79
8.1.220.0060.00317.74
8.1.210.0030.00518.77
8.1.200.0040.00417.35
8.1.190.0040.00417.55
8.1.180.0040.00420.54
8.1.170.0040.00418.64
8.1.160.0070.00022.27
8.1.150.0000.00718.63
8.1.140.0040.00417.52
8.1.130.0030.00517.86
8.1.120.0000.00817.50
8.1.110.0040.00417.40
8.1.100.0040.00417.39
8.1.90.0000.00717.52
8.1.80.0040.00317.52
8.1.70.0000.00717.48
8.1.60.0040.00417.52
8.1.50.0090.00017.52
8.1.40.0070.00017.54
8.1.30.0030.00617.63
8.1.20.0040.00417.56
8.1.10.0040.00417.54
8.1.00.0040.00417.46
8.0.300.0080.00018.77
8.0.290.0000.00716.88
8.0.280.0050.00318.30
8.0.270.0070.00017.20
8.0.260.0080.00016.80
8.0.250.0000.00716.89
8.0.240.0050.00316.89
8.0.230.0000.00716.88
8.0.220.0000.00716.89
8.0.210.0030.00316.83
8.0.200.0000.00717.08
8.0.190.0090.00017.09
8.0.180.0000.00716.90
8.0.170.0080.00016.97
8.0.160.0030.00516.94
8.0.150.0040.00416.98
8.0.140.0000.00716.87
8.0.130.0030.00513.51
8.0.120.0000.00816.92
8.0.110.0040.00416.96
8.0.100.0070.00016.95
8.0.90.0000.00816.78
8.0.80.0060.01516.88
8.0.70.0000.00716.88
8.0.60.0000.00816.99
8.0.50.0000.00817.11
8.0.30.0050.01317.30
8.0.20.0080.01017.40
8.0.10.0000.00717.22
8.0.00.0110.00716.76
7.4.330.0060.00015.09
7.4.320.0070.00016.49
7.4.300.0040.00416.63
7.4.290.0050.00316.55
7.4.280.0040.00416.64
7.4.270.0030.00316.50
7.4.260.0030.00316.53
7.4.250.0030.00516.65
7.4.240.0020.00516.56
7.4.230.0000.00716.48
7.4.220.0120.00316.75
7.4.210.0050.00916.57
7.4.200.0000.00816.73
7.4.190.0000.00816.40
7.4.160.0140.00316.53
7.4.150.0150.00317.40
7.4.140.0140.00917.86
7.4.130.0140.00916.55
7.4.120.0100.00816.63
7.4.110.0070.01116.59
7.4.100.0130.00416.61
7.4.90.0100.00716.61
7.4.80.0170.00719.39
7.4.70.0090.00916.38
7.4.60.0110.00616.67
7.4.50.0090.00016.52
7.4.40.0070.01022.77
7.4.30.0030.01216.64
7.4.00.0070.01014.86
7.3.330.0000.00513.45
7.3.320.0030.00313.43
7.3.310.0030.00316.32
7.3.300.0000.00716.39
7.3.290.0100.00316.35
7.3.280.0110.00616.44
7.3.270.0110.00717.40
7.3.260.0060.01316.40
7.3.250.0100.01016.62
7.3.240.0140.00416.53
7.3.230.0140.00516.55
7.3.210.0120.00616.40
7.3.200.0030.01419.39
7.3.190.0150.00016.62
7.3.180.0070.01016.56
7.3.170.0110.00516.49
7.3.160.0060.01016.55
7.3.120.0030.01215.03
7.3.10.0070.00716.53
7.3.00.0000.01316.42
7.2.330.0080.00816.84
7.2.320.0120.00616.84
7.2.310.0100.00716.84
7.2.300.0180.00016.80
7.2.290.0090.00916.79
7.2.130.0000.01516.68
7.2.120.0110.00416.99
7.2.110.0110.00017.07
7.2.100.0030.01016.93
7.2.90.0040.01217.16
7.2.80.0040.01116.95
7.2.70.0040.00717.09
7.2.60.0090.00616.95
7.2.50.0060.00616.56
7.2.40.0100.00316.93
7.2.30.0100.00317.02
7.2.20.0040.00916.86
7.2.10.0060.00616.89
7.2.00.0060.00817.07
7.1.250.0060.00615.69
7.1.200.0040.01115.79
7.1.70.0120.00317.19
7.1.60.0070.01419.82
7.1.50.0030.02016.89
7.1.00.0030.03322.32
7.0.200.0060.00616.76
7.0.140.0070.07022.05
7.0.90.0570.08020.04
7.0.80.0530.07319.94
7.0.70.0370.04719.92
7.0.60.0470.09019.94
7.0.50.0630.07320.34
7.0.40.0030.08020.19
7.0.30.0070.08020.13
7.0.20.0100.04720.00
7.0.10.0070.07719.99
7.0.00.0130.06320.03
5.6.280.0070.07020.88
5.6.240.0200.07320.65
5.6.230.0130.08020.55
5.6.220.0030.05020.63
5.6.210.0000.08320.68
5.6.200.0100.07721.10
5.6.190.0000.07721.04
5.6.180.0130.08320.96
5.6.170.0130.04321.03
5.6.160.0030.08721.15
5.6.150.0100.07321.01
5.6.140.0100.08021.00
5.6.130.0070.09321.12
5.6.120.0030.04321.12
5.6.110.0070.05321.03
5.6.100.0030.04721.01
5.6.90.0100.06020.95
5.6.80.0000.04020.45
5.6.70.0070.05020.44
5.6.60.0070.03720.34
5.6.50.0070.03720.43
5.6.40.0030.07020.46
5.6.30.0130.03020.31
5.6.20.0070.05320.48
5.6.10.0000.04320.42
5.6.00.0030.04020.44
5.5.380.0030.05020.53
5.5.370.0100.07720.43
5.5.360.0000.04720.37
5.5.350.0030.04720.41
5.5.340.0170.04720.89
5.5.330.0070.05320.75
5.5.320.0130.07720.90
5.5.310.0070.06320.90
5.5.300.0030.08020.90
5.5.290.0130.07320.86
5.5.280.0100.03720.75
5.5.270.0130.03320.65
5.5.260.0030.04720.82
5.5.250.0000.04320.75
5.5.240.0030.03720.20
5.5.230.0000.04020.22
5.5.220.0030.03320.13
5.5.210.0030.04020.13
5.5.200.0070.03720.20
5.5.190.0030.04020.10
5.5.180.0070.03720.25
5.5.160.0030.04020.01
5.5.150.0070.05320.26
5.5.140.0030.04720.25
5.5.130.0070.03720.28
5.5.120.0030.04020.17
5.5.110.0030.03720.13
5.5.100.0030.04020.12
5.5.90.0030.04020.07
5.5.80.0070.03020.09
5.5.70.0100.04720.16
5.5.60.0000.04020.07
5.5.50.0000.04720.02
5.5.40.0000.04720.05
5.5.30.0070.03720.06
5.5.20.0070.08020.15
5.5.10.0030.04320.04
5.5.00.0100.05020.05
5.4.450.0070.06719.47
5.4.440.0030.04019.27
5.4.430.0070.04019.35
5.4.420.0030.04019.37
5.4.410.0130.03019.05
5.4.400.0000.04018.88
5.4.390.0030.03718.95
5.4.380.0000.04019.09
5.4.370.0070.04719.09
5.4.360.0030.03719.04
5.4.350.0000.04019.12
5.4.340.0070.07319.05
5.4.320.0030.03718.95
5.4.310.0070.04719.13
5.4.300.0070.03718.93
5.4.290.0030.04319.06
5.4.280.0000.04318.88
5.4.270.0000.04019.20
5.4.260.0000.04018.87
5.4.250.0030.03318.90
5.4.240.0070.03319.13
5.4.230.0070.03318.87
5.4.220.0000.04019.12
5.4.210.0030.05719.13
5.4.200.0030.04318.94
5.4.190.0000.04019.11
5.4.180.0130.05019.03
5.4.170.0030.03318.84
5.4.160.0030.03719.07
5.4.150.0030.03719.02
5.4.140.0070.03016.50
5.4.130.0030.04016.41
5.4.120.0000.03716.43
5.4.110.0000.08316.37
5.4.100.0070.07316.49
5.4.90.0200.05716.42
5.4.80.0100.07016.38
5.4.70.0070.03716.50
5.4.60.0000.04316.41
5.4.50.0100.06716.40
5.4.40.0030.07716.49
5.4.30.0130.06716.46
5.4.20.0130.06016.41
5.4.10.0070.05316.25
5.4.00.0130.06715.82
5.3.290.0030.06314.68
5.3.280.0030.03314.72
5.3.270.0030.03714.61
5.3.260.0030.04314.58
5.3.250.0030.04014.57
5.3.240.0030.03714.67
5.3.230.0000.04014.63
5.3.220.0070.03014.64
5.3.210.0000.04014.70
5.3.200.0000.07714.56
5.3.190.0100.07714.68
5.3.180.0170.06314.55
5.3.170.0100.06014.66
5.3.160.0000.08014.68
5.3.150.0130.07714.54
5.3.140.0000.05314.66
5.3.130.0030.08014.69
5.3.120.0070.05714.70
5.3.110.0070.07314.55
5.3.100.0170.05314.11
5.3.90.0200.05714.07
5.3.80.0100.07014.04
5.3.70.0100.06714.15
5.3.60.0070.04014.08
5.3.50.0100.07713.96
5.3.40.0070.04314.01
5.3.30.0170.06313.93
5.3.20.0030.07313.82
5.3.10.0000.07313.69
5.3.00.0030.07313.58
5.2.170.0030.06011.14
5.2.160.0000.06311.17
5.2.150.0000.06011.07
5.2.140.0000.04011.07
5.2.130.0070.03311.20
5.2.120.0030.06011.23
5.2.110.0070.04311.01
5.2.100.0000.06711.00
5.2.90.0070.03311.12
5.2.80.0070.04011.13
5.2.70.0130.05711.13
5.2.60.0100.05711.10
5.2.50.0030.05010.98
5.2.40.0070.04711.11
5.2.30.0030.05311.04
5.2.20.0000.05711.04
5.2.10.0200.04310.93
5.2.00.0070.05310.80
5.1.60.0030.0539.86
5.1.50.0000.0579.84
5.1.40.0030.02710.11
5.1.30.0000.05710.36
5.1.20.0000.04010.37
5.1.10.0070.04010.07
5.1.00.0070.05310.19
5.0.50.0100.0238.41
5.0.40.0030.0438.45
5.0.30.0000.0638.25
5.0.20.0000.0478.29
5.0.10.0000.0338.31
5.0.00.0000.0378.28
4.4.90.0030.0337.38
4.4.80.0000.0377.38
4.4.70.0070.0307.38
4.4.60.0030.0337.38
4.4.50.0000.0377.38
4.4.40.0000.0507.38
4.4.30.0030.0237.38
4.4.20.0070.0307.38
4.4.10.0070.0207.38
4.4.00.0030.0537.38
4.3.110.0000.0237.38
4.3.100.0000.0177.38
4.3.90.0030.0337.38
4.3.80.0030.0507.38
4.3.70.0030.0237.38
4.3.60.0070.0207.38
4.3.50.0000.0407.38
4.3.40.0030.0507.38
4.3.30.0000.0377.38
4.3.20.0000.0377.38
4.3.10.0000.0377.38
4.3.00.0000.0377.38

preferences:
39 ms | 400 KiB | 5 Q