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; $obj = (object) $arr; 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.0060.00918.68
8.3.50.0070.00921.27
8.3.40.0130.00618.84
8.3.30.0070.00719.23
8.3.20.0000.00720.35
8.3.10.0080.00021.83
8.3.00.0040.00422.57
8.2.180.0100.00616.75
8.2.170.0070.00722.96
8.2.160.0100.00719.16
8.2.150.0060.00324.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0080.00019.66
8.2.110.0040.00422.24
8.2.100.0040.00719.38
8.2.90.0060.00319.22
8.2.80.0060.00318.16
8.2.70.0030.00617.48
8.2.60.0080.00018.04
8.2.50.0060.00318.07
8.2.40.0050.00518.22
8.2.30.0040.00418.02
8.2.20.0000.00817.84
8.2.10.0060.00317.69
8.2.00.0070.00417.79
8.1.280.0100.01025.92
8.1.270.0040.00421.95
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00023.79
8.1.230.0040.00819.10
8.1.220.0060.00317.74
8.1.210.0000.00818.77
8.1.200.0040.00417.23
8.1.190.0050.00317.52
8.1.180.0040.00420.51
8.1.170.0050.00318.51
8.1.160.0000.00722.29
8.1.150.0040.00418.71
8.1.140.0030.00617.51
8.1.130.0050.00217.78
8.1.120.0040.00417.47
8.1.110.0040.00417.38
8.1.100.0000.00717.41
8.1.90.0050.00217.40
8.1.80.0000.00717.49
8.1.70.0030.00317.46
8.1.60.0030.00517.59
8.1.50.0000.00717.56
8.1.40.0000.00817.45
8.1.30.0000.00817.73
8.1.20.0030.00617.59
8.1.10.0030.00517.60
8.1.00.0000.00917.57
8.0.300.0070.00018.77
8.0.290.0040.00417.05
8.0.280.0000.00818.27
8.0.270.0070.00017.23
8.0.260.0000.00716.84
8.0.250.0070.00016.93
8.0.240.0040.00416.83
8.0.230.0000.00717.05
8.0.220.0000.00716.80
8.0.210.0030.00316.84
8.0.200.0000.00616.94
8.0.190.0030.00516.93
8.0.180.0040.00417.04
8.0.170.0060.00316.91
8.0.160.0000.00817.04
8.0.150.0040.00417.00
8.0.140.0000.00716.98
8.0.130.0060.00313.50
8.0.120.0040.00416.97
8.0.110.0000.00816.90
8.0.100.0070.00016.99
8.0.90.0050.00317.04
8.0.80.0120.00317.04
8.0.70.0080.00016.88
8.0.60.0050.00316.86
8.0.50.0000.00717.01
8.0.30.0120.00717.14
8.0.20.0050.01317.40
8.0.10.0000.00717.01
8.0.00.0140.00616.80
7.4.330.0040.00015.00
7.4.320.0000.00616.49
7.4.300.0030.00316.55
7.4.290.0030.00516.63
7.4.280.0040.00416.52
7.4.270.0070.00016.56
7.4.260.0070.00016.43
7.4.250.0040.00416.52
7.4.240.0040.00416.57
7.4.230.0000.00716.57
7.4.220.0030.01216.60
7.4.210.0080.00816.61
7.4.200.0000.00716.75
7.4.190.0000.00816.45
7.4.160.0100.01416.72
7.4.150.0070.01017.40
7.4.140.0080.01717.86
7.4.130.0050.01516.63
7.4.120.0080.00816.62
7.4.110.0140.00316.76
7.4.100.0110.00716.50
7.4.90.0140.00716.67
7.4.80.0040.02019.39
7.4.70.0100.01016.56
7.4.60.0060.01016.51
7.4.50.0000.00516.41
7.4.40.0040.00822.77
7.4.30.0050.01216.50
7.4.00.0040.01414.80
7.3.330.0000.00513.23
7.3.320.0020.00213.38
7.3.310.0070.00016.44
7.3.300.0000.00716.41
7.3.290.0080.00616.52
7.3.280.0100.00816.42
7.3.270.0100.00717.40
7.3.260.0070.01116.42
7.3.250.0130.00416.64
7.3.240.0100.00716.58
7.3.230.0140.00416.51
7.3.210.0180.00016.39
7.3.200.0090.00919.39
7.3.190.0160.00716.41
7.3.180.0060.01116.52
7.3.170.0120.00316.50
7.3.160.0160.00016.54
7.3.120.0060.00615.00
7.2.330.0060.01216.83
7.2.320.0060.01016.53
7.2.310.0070.01016.77
7.2.300.0070.01116.61
7.2.290.0070.01016.85
7.2.60.0140.00017.01
7.1.200.0090.00015.61
7.1.70.0040.00816.85
7.1.60.0090.00919.82
7.1.50.0030.01416.86
7.1.00.0070.06722.31
7.0.201.1430.00314.73
7.0.140.0070.06721.98
7.0.90.0070.05020.02
7.0.80.0100.07720.04
7.0.70.0770.06720.05
7.0.60.0700.06719.83
7.0.50.0730.08320.37
7.0.40.0000.09020.08
7.0.30.0030.07020.17
7.0.20.0100.04720.09
7.0.10.0030.06320.05
7.0.00.0070.04320.13
5.6.280.0000.07721.15
5.6.240.0030.05720.65
5.6.230.0070.09020.70
5.6.220.0130.06020.60
5.6.210.0100.06720.77
5.6.200.0130.07721.12
5.6.190.0000.05020.98
5.6.180.0130.07321.08
5.6.170.0070.08320.98
5.6.160.0070.05721.18
5.6.150.0070.08321.02
5.6.140.0070.05021.01
5.6.130.0170.08020.97
5.6.120.0130.08721.04
5.6.110.0200.07020.96
5.6.100.0130.07321.17
5.6.90.0030.05021.11
5.6.80.0070.08320.44
5.6.70.0130.04720.48
5.6.60.0070.06320.49
5.6.50.0100.07320.53
5.6.40.0130.07320.41
5.6.30.0070.04720.41
5.6.20.0100.04020.32
5.6.10.0030.07720.48
5.6.00.0130.07020.31
5.5.380.0070.07020.36
5.5.370.0130.06020.46
5.5.360.0030.08720.37
5.5.350.0100.05320.44
5.5.340.0130.06020.88
5.5.330.0070.07020.95
5.5.320.0030.07020.75
5.5.310.0100.07320.79
5.5.300.0000.05320.77
5.5.290.0070.08720.81
5.5.280.0100.06020.75
5.5.270.0100.08020.64
5.5.260.0100.04320.84
5.5.250.0130.06720.69
5.5.240.0070.05320.14
5.5.230.0130.06720.29
5.5.220.0130.08020.04
5.5.210.0100.05020.29
5.5.200.0030.07720.25
5.5.190.0100.06720.24
5.5.180.0100.07720.25
5.5.160.0100.07320.24
5.5.150.0070.04320.16
5.5.140.0000.04320.27
5.5.130.0030.08320.20
5.5.120.0070.08020.23
5.5.110.0070.06720.23
5.5.100.0100.03320.07
5.5.90.0130.07720.18
5.5.80.0130.06720.14
5.5.70.0030.07720.07
5.5.60.0030.08020.07
5.5.50.0100.04320.09
5.5.40.0030.08720.08
5.5.30.0170.08020.11
5.5.20.0200.06720.04
5.5.10.0100.08020.05
5.5.00.0070.08020.15
5.4.450.0030.08319.47
5.4.440.0070.07719.39
5.4.430.0130.07719.57
5.4.420.0070.07319.28
5.4.410.0170.04019.14
5.4.400.0130.07019.18
5.4.390.0130.07319.21
5.4.380.0070.07318.90
5.4.370.0130.06719.06
5.4.360.0100.06019.21
5.4.350.0130.07319.07
5.4.340.0100.06718.88
5.4.320.0070.07318.91
5.4.310.0030.05719.13
5.4.300.0070.04719.13
5.4.290.0100.03719.14
5.4.280.0170.07719.03
5.4.270.0130.07319.18
5.4.260.0030.04319.16
5.4.250.0000.04718.84
5.4.240.0130.06719.04
5.4.230.0000.08319.22
5.4.220.0170.06019.09
5.4.210.0070.04019.25
5.4.200.0170.06018.98
5.4.190.0070.05319.14
5.4.180.0130.06318.89
5.4.170.0030.08019.11
5.4.160.0000.05319.12
5.4.150.0200.05319.21
5.4.140.0000.05716.44
5.4.130.0070.07716.44
5.4.120.0070.03716.43
5.4.110.0030.05016.44
5.4.100.0070.07316.48
5.4.90.0030.06016.49
5.4.80.0100.07016.47
5.4.70.0100.07016.38
5.4.60.0130.05716.48
5.4.50.0130.07316.36
5.4.40.0070.07716.30
5.4.30.0070.04016.45
5.4.20.0130.07016.45
5.4.10.0030.03716.48
5.4.00.0130.07015.75
5.3.290.0130.06714.69
5.3.280.0100.07014.60
5.3.270.0000.08014.59
5.3.260.0100.04714.73
5.3.250.0170.05014.61
5.3.240.0070.04314.68
5.3.230.0030.05014.61
5.3.220.0100.07014.64
5.3.210.0070.08014.57
5.3.200.0100.04714.57
5.3.190.0070.08014.64
5.3.180.0000.08014.70
5.3.170.0100.04314.51
5.3.160.0070.06714.70
5.3.150.0100.04314.53
5.3.140.0100.06314.50
5.3.130.0100.03014.57
5.3.120.0100.04714.70
5.3.110.0000.05014.64
5.3.100.0030.06014.00
5.3.90.0070.04314.04
5.3.80.0130.03314.15
5.3.70.0030.04314.05
5.3.60.0030.07714.05
5.3.50.0000.04714.07
5.3.40.0070.03713.98
5.3.30.0000.03714.04
5.3.20.0030.03313.71
5.3.10.0000.04313.56
5.3.00.0000.03713.71
5.2.170.0070.03711.29
5.2.160.0000.03311.08
5.2.150.0000.03311.27
5.2.140.0100.02311.05
5.2.130.0030.02711.18
5.2.120.0070.04711.02
5.2.110.0030.03311.04
5.2.100.0000.03011.17
5.2.90.0030.02311.25
5.2.80.0000.03011.21
5.2.70.0030.02311.03
5.2.60.0000.03310.95
5.2.50.0030.03011.18
5.2.40.0000.03011.08
5.2.30.0000.02710.97
5.2.20.0000.03011.07
5.2.10.0100.04710.73
5.2.00.0030.03710.75
5.1.60.0000.02710.00
5.1.50.0000.02710.00
5.1.40.0000.0309.88
5.1.30.0000.02710.38
5.1.20.0030.02710.48
5.1.10.0000.02710.17
5.1.00.0000.05010.16
5.0.50.0030.0208.41
5.0.40.0000.0208.53
5.0.30.0000.0308.09
5.0.20.0030.0178.07
5.0.10.0030.0178.25
5.0.00.0000.0308.18
4.4.90.0000.0137.18
4.4.80.0030.0137.18
4.4.70.0000.0177.18
4.4.60.0000.0137.18
4.4.50.0030.0137.18
4.4.40.0000.0237.18
4.4.30.0030.0137.18
4.4.20.0030.0107.18
4.4.10.0000.0207.18
4.4.00.0000.0237.18
4.3.110.0030.0137.18
4.3.100.0000.0137.18
4.3.90.0000.0137.18
4.3.80.0030.0207.18
4.3.70.0030.0107.18
4.3.60.0000.0137.18
4.3.50.0070.0107.18
4.3.40.0000.0237.18
4.3.30.0000.0137.18
4.3.20.0030.0107.18
4.3.10.0000.0207.18
4.3.00.0000.0137.18

preferences:
34.68 ms | 401 KiB | 5 Q