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); $arr = (array) $obj; $out = json_encode($arr); var_dump($out); //$obj = (object) $arr; //$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.0030.01618.30
8.3.50.0140.00321.27
8.3.40.0140.00718.84
8.3.30.0150.00619.16
8.3.20.0020.00520.29
8.3.10.0040.00421.73
8.3.00.0030.00522.44
8.2.180.0120.00316.75
8.2.170.0100.01022.96
8.2.160.0140.00019.27
8.2.150.0050.00224.18
8.2.140.0040.00424.66
8.2.130.0100.00726.16
8.2.120.0040.00419.66
8.2.110.0060.00320.54
8.2.100.0080.00317.91
8.2.90.0080.00019.26
8.2.80.0080.00017.97
8.2.70.0000.00917.63
8.2.60.0080.00018.04
8.2.50.0040.00418.07
8.2.40.0030.00718.22
8.2.30.0000.00718.11
8.2.20.0040.00417.68
8.2.10.0000.00817.90
8.2.00.0060.00317.79
8.1.280.0100.01025.92
8.1.270.0080.00022.20
8.1.260.0030.00526.35
8.1.250.0080.00028.09
8.1.240.0050.00521.13
8.1.230.0040.00717.46
8.1.220.0060.00317.76
8.1.210.0050.00318.77
8.1.200.0030.00717.35
8.1.190.0000.00817.55
8.1.180.0030.00520.60
8.1.170.0000.00818.66
8.1.160.0030.00322.09
8.1.150.0000.00718.60
8.1.140.0070.00017.47
8.1.130.0030.00317.93
8.1.120.0070.00017.36
8.1.110.0050.00317.52
8.1.100.0050.00217.50
8.1.90.0000.00717.51
8.1.80.0030.00517.50
8.1.70.0000.00817.40
8.1.60.0060.00317.61
8.1.50.0030.00517.55
8.1.40.0060.00317.59
8.1.30.0030.00517.57
8.1.20.0060.00317.66
8.1.10.0050.00217.64
8.1.00.0000.00817.51
8.0.300.0050.00218.77
8.0.290.0050.00316.59
8.0.280.0070.00018.43
8.0.270.0030.00317.23
8.0.260.0060.00316.80
8.0.250.0070.00017.04
8.0.240.0000.00917.01
8.0.230.0000.00816.95
8.0.220.0070.00016.90
8.0.210.0070.00016.91
8.0.200.0000.00716.94
8.0.190.0000.00817.10
8.0.180.0000.00716.92
8.0.170.0030.00516.99
8.0.160.0030.00516.94
8.0.150.0000.00716.91
8.0.140.0070.00016.86
8.0.130.0050.00013.46
8.0.120.0040.00416.88
8.0.110.0000.00716.87
8.0.100.0000.00816.94
8.0.90.0040.00417.11
8.0.80.0030.01316.94
8.0.70.0040.00416.86
8.0.60.0000.00817.00
8.0.50.0000.00816.79
8.0.30.0080.01016.90
8.0.20.0090.01317.40
8.0.10.0000.00717.23
8.0.00.0070.01216.98
7.4.330.0030.00315.10
7.4.320.0060.00016.60
7.4.300.0000.00616.62
7.4.290.0000.00716.66
7.4.280.0030.00316.44
7.4.270.0050.00316.65
7.4.260.0080.00016.57
7.4.250.0040.00416.61
7.4.240.0020.00516.65
7.4.230.0000.00716.36
7.4.220.0070.01016.52
7.4.210.0070.00816.54
7.4.200.0040.00416.44
7.4.190.0030.00316.51
7.4.160.0030.01416.42
7.4.150.0120.00617.40
7.4.140.0150.00617.86
7.4.130.0040.01516.46
7.4.120.0160.00216.67
7.4.110.0030.01316.51
7.4.100.0120.00916.61
7.4.90.0030.01416.61
7.4.80.0130.01219.39
7.4.70.0140.00316.54
7.4.60.0100.00716.64
7.4.50.0030.00616.38
7.4.40.0100.00722.77
7.4.30.0080.01616.59
7.4.00.0070.01015.22
7.3.330.0030.00313.36
7.3.320.0000.00513.31
7.3.310.0020.00516.46
7.3.300.0030.00316.45
7.3.290.0070.00716.32
7.3.280.0110.00516.43
7.3.270.0070.01017.40
7.3.260.0090.00916.44
7.3.250.0130.00716.54
7.3.240.0080.00816.49
7.3.230.0130.00916.55
7.3.210.0070.01016.47
7.3.200.0060.01319.39
7.3.190.0080.01516.34
7.3.180.0060.01216.56
7.3.170.0080.00816.45
7.3.160.0080.00816.50
7.3.120.0030.00914.93
7.3.10.0070.00616.66
7.3.00.0040.00716.65
7.2.330.0090.00916.89
7.2.320.0060.01016.47
7.2.310.0030.02116.48
7.2.300.0060.01216.75
7.2.290.0030.01416.79
7.2.130.0040.00916.56
7.2.120.0060.00716.81
7.2.110.0120.00516.88
7.2.100.0070.00616.87
7.2.90.0010.01216.80
7.2.80.0060.00816.94
7.2.70.0070.00716.82
7.2.60.0090.00816.81
7.2.50.0110.00516.96
7.2.40.0060.00916.86
7.2.30.0020.01217.04
7.2.20.0100.00716.91
7.2.10.0140.00416.81
7.2.00.0140.00417.81
7.1.250.0070.00615.60
7.1.200.0060.00615.88
7.1.100.0070.00317.86
7.1.70.0050.00517.11
7.1.60.0100.01319.82
7.1.50.0000.01416.97
7.1.00.0000.04322.44
7.0.200.1560.00016.52
7.0.140.0030.07321.95
7.0.90.0330.03720.03
7.0.80.0270.04020.04
7.0.70.0670.07720.06
7.0.60.0570.08019.79
7.0.50.0570.06320.39
7.0.40.0170.05320.08
7.0.30.0100.08720.04
7.0.20.0130.07720.13
7.0.10.0000.05320.07
7.0.00.0100.06019.99
5.6.280.0070.06721.14
5.6.240.0130.03320.68
5.6.230.0070.03720.64
5.6.220.0130.06320.59
5.6.210.0000.06720.67
5.6.200.0130.08020.96
5.6.190.0100.08021.15
5.6.180.0030.08321.05
5.6.170.0100.08020.95
5.6.160.0100.07321.06
5.6.150.0100.08020.95
5.6.140.0100.05321.07
5.6.130.0030.08721.09
5.6.120.0100.04021.06
5.6.110.0030.08321.14
5.6.100.0130.06321.11
5.6.90.0100.07721.11
5.6.80.0130.06720.42
5.6.70.0100.07020.47
5.6.60.0000.05720.52
5.6.50.0200.06720.49
5.6.40.0100.04320.31
5.6.30.0070.08020.39
5.6.20.0100.07320.32
5.6.10.0100.08020.32
5.6.00.0100.07720.30
5.5.380.0100.04320.44
5.5.370.0030.04020.35
5.5.360.0100.08020.42
5.5.350.0100.08020.44
5.5.340.0100.07720.85
5.5.330.0100.04020.94
5.5.320.0200.07020.91
5.5.310.0200.07020.90
5.5.300.0170.07020.84
5.5.290.0100.07720.88
5.5.280.0100.08020.79
5.5.270.0030.05720.90
5.5.260.0070.08320.80
5.5.250.0100.05320.75
5.5.240.0100.06720.05
5.5.230.0130.04020.22
5.5.220.0130.07720.29
5.5.210.0170.07720.15
5.5.200.0100.07320.21
5.5.190.0130.07320.24
5.5.180.0130.06720.16
5.5.160.0100.07320.24
5.5.150.0030.08320.22
5.5.140.0030.04320.28
5.5.130.0130.06720.09
5.5.120.0070.07720.24
5.5.110.0000.08720.29
5.5.100.0100.05320.10
5.5.90.0100.07020.06
5.5.80.0000.04720.02
5.5.70.0170.07320.11
5.5.60.0030.08020.02
5.5.50.0000.05020.15
5.5.40.0130.06320.13
5.5.30.0100.06020.09
5.5.20.0070.04720.10
5.5.10.0070.08020.04
5.5.00.0030.08320.05
5.4.450.0070.08319.20
5.4.440.0000.07719.54
5.4.430.0000.06719.45
5.4.420.0170.03719.53
5.4.410.0130.07019.31
5.4.400.0130.05319.14
5.4.390.0070.04719.13
5.4.380.0030.07718.85
5.4.370.0100.05719.09
5.4.360.0070.07719.05
5.4.350.0030.04719.23
5.4.340.0070.05019.04
5.4.320.0100.07019.05
5.4.310.0100.07319.04
5.4.300.0100.07018.90
5.4.290.0030.06318.90
5.4.280.0100.07719.09
5.4.270.0000.08719.03
5.4.260.0000.08718.96
5.4.250.0100.06319.21
5.4.240.0000.08019.20
5.4.230.0030.04718.89
5.4.220.0100.04019.11
5.4.210.0030.07318.86
5.4.200.0070.07319.15
5.4.190.0030.04019.03
5.4.180.0070.06719.03
5.4.170.0070.07319.03
5.4.160.0030.08319.11
5.4.150.0000.05019.19
5.4.140.0100.07316.46
5.4.130.0070.06716.43
5.4.120.0000.07316.41
5.4.110.0130.05016.56
5.4.100.0030.03716.52
5.4.90.0070.06716.40
5.4.80.0000.04716.31
5.4.70.0100.06716.43
5.4.60.0100.06716.50
5.4.50.0030.07716.36
5.4.40.0030.04316.54
5.4.30.0030.07316.35
5.4.20.0070.07016.48
5.4.10.0030.06716.39
5.4.00.0030.05715.60
5.3.290.0000.05014.75
5.3.280.0070.05314.68
5.3.270.0000.08714.56
5.3.260.0070.05014.65
5.3.250.0070.07014.57
5.3.240.0100.07014.68
5.3.230.0070.04714.73
5.3.220.0100.04014.72
5.3.210.0100.05014.66
5.3.200.0000.06014.69
5.3.190.0000.08014.58
5.3.180.0070.07314.60
5.3.170.0070.06714.57
5.3.160.0030.04714.46
5.3.150.0000.07314.61
5.3.140.0030.04314.58
5.3.130.0100.05014.52
5.3.120.0130.07014.70
5.3.110.0000.05314.57
5.3.100.0070.05014.05
5.3.90.0070.07013.97
5.3.80.0130.07014.09
5.3.70.0030.05714.14
5.3.60.0030.05714.07
5.3.50.0000.05014.11
5.3.40.0070.04713.98
5.3.30.0070.07713.99
5.3.20.0100.05713.64
5.3.10.0100.07313.68
5.3.00.0000.07013.72
5.2.170.0030.04711.25
5.2.160.0070.03311.14
5.2.150.0030.06711.24
5.2.140.0100.05011.01
5.2.130.0100.05711.13
5.2.120.0030.05311.01
5.2.110.0070.05711.22
5.2.100.0070.05011.14
5.2.90.0000.06711.02
5.2.80.0130.05311.22
5.2.70.0070.06311.23
5.2.60.0170.05311.13
5.2.50.0070.04311.09
5.2.40.0030.05311.02
5.2.30.0170.03311.00
5.2.20.0130.05310.89
5.2.10.0030.04710.90
5.2.00.0070.05710.79
5.1.60.0030.05310.05
5.1.50.0100.05010.05
5.1.40.0030.05010.07
5.1.30.0070.06010.37
5.1.20.0130.04710.32
5.1.10.0030.05310.07
5.1.00.0070.05010.17
5.0.50.0030.0308.41
5.0.40.0070.0408.33
5.0.30.0030.0538.28
5.0.20.0030.0408.27
5.0.10.0070.0308.05
5.0.00.0130.0538.02
4.4.90.0000.0377.18
4.4.80.0000.0377.18
4.4.70.0070.0237.18
4.4.60.0000.0237.18
4.4.50.0030.0337.18
4.4.40.0030.0537.18
4.4.30.0000.0307.18
4.4.20.0130.0237.18
4.4.10.0030.0337.18
4.4.00.0030.0577.18
4.3.110.0000.0377.18
4.3.100.0100.0277.18
4.3.90.0030.0337.18
4.3.80.0030.0377.18
4.3.70.0000.0377.18
4.3.60.0000.0307.18
4.3.50.0000.0237.18
4.3.40.0000.0377.18
4.3.30.0030.0207.18
4.3.20.0030.0207.18
4.3.10.0000.0237.18
4.3.00.0000.0377.18

preferences:
55.8 ms | 401 KiB | 5 Q