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'] = '1234'; $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.55
8.3.50.0130.00521.09
8.3.40.0180.00418.84
8.3.30.0120.00319.04
8.3.20.0080.00020.29
8.3.10.0080.00021.97
8.3.00.0060.00320.61
8.2.180.0110.00416.75
8.2.170.0100.00322.96
8.2.160.0070.00719.26
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0110.00726.16
8.2.120.0080.00019.66
8.2.110.0080.00022.01
8.2.100.0000.01119.34
8.2.90.0000.00819.36
8.2.80.0040.00417.97
8.2.70.0030.00617.73
8.2.60.0090.00017.93
8.2.50.0050.00318.07
8.2.40.0060.00318.11
8.2.30.0040.00418.18
8.2.20.0080.00017.72
8.2.10.0060.00317.75
8.2.00.0060.00517.93
8.1.280.0140.00725.92
8.1.270.0040.00422.05
8.1.260.0080.00026.35
8.1.250.0090.00028.09
8.1.240.0080.00323.83
8.1.230.0060.00619.15
8.1.220.0040.00417.89
8.1.210.0090.00018.77
8.1.200.0070.00317.35
8.1.190.0080.00017.41
8.1.180.0000.00820.52
8.1.170.0000.00818.70
8.1.160.0040.00422.19
8.1.150.0040.00418.68
8.1.140.0030.00617.51
8.1.130.0070.00017.98
8.1.120.0000.00817.50
8.1.110.0070.00017.47
8.1.100.0040.00317.41
8.1.90.0000.00817.50
8.1.80.0000.00717.49
8.1.70.0070.00017.48
8.1.60.0030.00617.64
8.1.50.0020.00517.46
8.1.40.0040.00417.54
8.1.30.0040.00417.68
8.1.20.0040.00417.71
8.1.10.0080.00017.52
8.1.00.0040.00417.59
8.0.300.0070.00018.77
8.0.290.0030.00617.05
8.0.280.0000.00818.41
8.0.270.0000.00717.30
8.0.260.0030.00317.04
8.0.250.0070.00017.09
8.0.240.0060.00317.05
8.0.230.0000.00717.06
8.0.220.0000.00716.88
8.0.210.0000.00716.96
8.0.200.0000.00617.06
8.0.190.0050.00317.04
8.0.180.0020.00516.96
8.0.170.0050.00316.96
8.0.160.0050.00216.95
8.0.150.0070.00016.89
8.0.140.0040.00417.04
8.0.130.0000.00813.31
8.0.120.0040.00417.00
8.0.110.0040.00417.01
8.0.100.0000.00716.88
8.0.90.0040.00417.05
8.0.80.0100.01017.05
8.0.70.0040.00417.08
8.0.60.0040.00417.00
8.0.50.0000.00716.87
8.0.30.0070.01117.26
8.0.20.0090.00917.41
8.0.10.0000.00717.09
8.0.00.0090.01216.70
7.4.330.0000.00415.00
7.4.320.0000.00716.65
7.4.300.0000.00716.43
7.4.290.0000.00716.55
7.4.280.0030.00316.56
7.4.270.0000.00816.49
7.4.260.0030.00316.54
7.4.250.0040.00416.53
7.4.240.0040.00316.51
7.4.230.0000.00616.54
7.4.220.0040.01116.62
7.4.210.0100.00716.55
7.4.200.0000.00716.54
7.4.190.0070.00016.70
7.4.160.0110.00616.63
7.4.150.0220.00317.40
7.4.140.0100.00817.86
7.4.130.0070.01116.47
7.4.120.0090.00916.57
7.4.110.0170.00016.46
7.4.100.0000.02116.62
7.4.90.0070.01116.64
7.4.80.0160.00019.39
7.4.70.0110.00616.68
7.4.60.0070.01016.72
7.4.50.0030.00516.23
7.4.40.0090.00622.77
7.4.30.0030.01416.54
7.4.00.0050.01214.98
7.3.330.0050.00013.25
7.3.320.0060.00013.40
7.3.310.0000.00716.34
7.3.300.0000.00916.38
7.3.290.0100.00316.41
7.3.280.0110.00516.44
7.3.270.0140.00417.40
7.3.260.0170.00316.33
7.3.250.0090.00916.41
7.3.240.0170.00016.54
7.3.230.0100.01116.41
7.3.210.0100.01016.34
7.3.200.0130.00416.60
7.3.190.0090.00616.57
7.3.180.0060.00916.45
7.3.170.0040.01316.50
7.3.160.0030.01316.61
7.3.120.0110.00614.99
7.3.110.0090.00915.04
7.3.100.0040.01114.90
7.3.90.0050.00715.01
7.3.80.0050.00814.91
7.3.70.0090.00614.88
7.3.60.0070.00714.95
7.3.50.0060.00614.81
7.3.40.0070.00614.87
7.3.30.0080.00714.61
7.3.20.0030.01016.72
7.3.10.0020.01116.59
7.3.00.0050.00616.66
7.2.330.0070.01116.78
7.2.320.0100.00716.77
7.2.310.0080.00816.72
7.2.300.0120.00816.74
7.2.290.0110.00716.68
7.2.250.0060.01115.20
7.2.240.0080.01015.26
7.2.230.0050.01015.01
7.2.220.0080.00215.07
7.2.210.0030.01114.95
7.2.200.0060.00614.96
7.2.190.0060.01114.99
7.2.180.0040.01314.92
7.2.170.0100.00615.19
7.2.160.0040.00715.04
7.2.150.0100.00717.04
7.2.140.0070.00417.11
7.2.130.0080.00916.91
7.2.120.0030.01316.89
7.2.110.0050.00616.83
7.2.100.0080.00816.89
7.2.90.0030.01016.94
7.2.80.0060.00916.94
7.2.70.0030.00616.88
7.2.60.0080.00516.86
7.2.50.0020.01417.01
7.2.40.0080.00516.92
7.2.30.0080.00316.87
7.2.20.0070.00916.96
7.2.10.0080.00716.79
7.2.00.0040.00817.83
7.1.330.0000.01515.71
7.1.320.0040.00615.86
7.1.310.0090.00615.76
7.1.300.0040.00615.64
7.1.290.0090.00315.87
7.1.280.0030.01015.86
7.1.270.0100.00115.89
7.1.260.0040.00815.74
7.1.250.0060.00515.69
7.1.200.0060.00315.89
7.1.100.0110.00818.20
7.1.70.0030.01017.17
7.1.60.0100.01319.82
7.1.50.0040.00716.99
7.1.00.0000.08022.35
7.0.200.0000.00716.80
7.0.140.0070.07022.13
7.0.90.0070.07319.93
7.0.80.0070.07319.99
7.0.70.0070.08719.95
7.0.60.0200.05719.98
7.0.50.0070.05720.32
7.0.40.0070.08320.00
7.0.30.0200.07320.09
7.0.20.0070.08020.14
7.0.10.0070.04720.08
7.0.00.0100.08020.07
5.6.280.0070.07021.01
5.6.240.0030.08020.62
5.6.230.0100.05020.63
5.6.220.0070.08320.58
5.6.210.0070.07320.61
5.6.200.0100.08021.10
5.6.190.0100.04021.05
5.6.180.0070.08321.06
5.6.170.0030.08020.97
5.6.160.0070.04021.12
5.6.150.0130.07721.04
5.6.140.0100.07720.96
5.6.130.0100.06021.03
5.6.120.0170.07020.97
5.6.110.0070.04720.96
5.6.100.0100.05320.94
5.6.90.0030.06021.01
5.6.80.0130.07020.41
5.6.70.0000.08320.41
5.6.60.0100.04720.43
5.6.50.0100.08320.42
5.6.40.0070.08020.29
5.6.30.0070.07720.52
5.6.20.0070.04320.45
5.6.10.0100.07720.47
5.6.00.0030.05320.30
5.5.380.0000.08320.38
5.5.370.0070.08020.42
5.5.360.0130.07320.38
5.5.350.0030.05320.36
5.5.340.0100.07720.66
5.5.330.0030.08020.89
5.5.320.0030.08320.88
5.5.310.0130.07320.90
5.5.300.0030.07020.65
5.5.290.0100.04320.85
5.5.280.0100.07720.80
5.5.270.0030.05020.81
5.5.260.0070.04320.83
5.5.250.0030.08020.71
5.5.240.0070.05320.04
5.5.230.0070.07720.29
5.5.220.0100.07720.21
5.5.210.0100.07320.23
5.5.200.0230.04320.20
5.5.190.0100.07720.30
5.5.180.0100.07720.20
5.5.160.0030.05720.17
5.5.150.0030.08320.25
5.5.140.0070.08320.12
5.5.130.0130.04720.16
5.5.120.0070.05320.18
5.5.110.0200.07320.17
5.5.100.0070.07320.13
5.5.90.0170.03020.14
5.5.80.0000.04319.99
5.5.70.0100.06720.08
5.5.60.0000.04320.09
5.5.50.0070.07020.02
5.5.40.0070.04320.05
5.5.30.0130.06320.07
5.5.20.0170.06719.95
5.5.10.0070.08020.05
5.5.00.0030.04019.95
5.4.450.0000.08319.36
5.4.440.0170.06319.49
5.4.430.0000.06319.45
5.4.420.0100.06719.53
5.4.410.0070.08319.24
5.4.400.0100.07318.88
5.4.390.0070.07319.13
5.4.380.0070.05019.09
5.4.370.0070.05319.20
5.4.360.0030.07719.13
5.4.350.0070.07319.12
5.4.340.0170.07019.16
5.4.320.0100.05719.05
5.4.310.0100.04719.13
5.4.300.0070.07318.84
5.4.290.0070.08019.20
5.4.280.0100.07018.84
5.4.270.0170.06719.00
5.4.260.0030.04719.03
5.4.250.0070.06019.20
5.4.240.0130.06019.17
5.4.230.0070.08018.84
5.4.220.0000.05719.11
5.4.210.0070.05019.20
5.4.200.0070.04718.86
5.4.190.0000.04719.20
5.4.180.0070.07718.86
5.4.170.0070.04319.02
5.4.160.0070.06719.07
5.4.150.0170.06319.18
5.4.140.0130.05016.34
5.4.130.0030.06016.36
5.4.120.0000.05016.41
5.4.110.0130.02716.54
5.4.100.0070.05016.53
5.4.90.0030.07716.49
5.4.80.0100.07016.51
5.4.70.0170.05016.50
5.4.60.0100.07016.40
5.4.50.0100.04016.40
5.4.40.0100.06316.42
5.4.30.0100.06716.44
5.4.20.0000.07716.45
5.4.10.0070.04016.48
5.4.00.0030.03715.80
5.3.290.0100.07714.68
5.3.280.0130.06714.57
5.3.270.0030.05314.56
5.3.260.0030.06014.67
5.3.250.0030.04314.68
5.3.240.0100.05314.73
5.3.230.0030.05714.72
5.3.220.0070.04314.52
5.3.210.0030.05314.64
5.3.200.0100.05314.64
5.3.190.0030.05314.71
5.3.180.0170.06314.50
5.3.170.0070.07714.68
5.3.160.0100.06714.52
5.3.150.0070.07314.54
5.3.140.0030.07714.50
5.3.130.0170.04314.57
5.3.120.0030.04714.49
5.3.110.0030.05014.70
5.3.100.0030.07714.11
5.3.90.0070.07714.02
5.3.80.0070.05014.09
5.3.70.0070.06314.14
5.3.60.0100.03714.14
5.3.50.0000.08013.95
5.3.40.0100.06314.10
5.3.30.0100.07013.81
5.3.20.0070.05013.63
5.3.10.0070.06013.65
5.3.00.0030.05013.57
5.2.170.0130.05311.04
5.2.160.0030.06011.26
5.2.150.0100.04711.25
5.2.140.0100.05311.25
5.2.130.0030.05711.00
5.2.120.0070.03011.21
5.2.110.0070.05711.13
5.2.100.0070.03711.22
5.2.90.0030.06011.17
5.2.80.0000.03311.20
5.2.70.0000.03711.16
5.2.60.0030.06311.18
5.2.50.0030.06311.07
5.2.40.0030.05711.13
5.2.30.0000.06711.01
5.2.20.0130.05011.03
5.2.10.0070.05311.00
5.2.00.0070.05010.66
5.1.60.0100.04710.09
5.1.50.0070.05310.11
5.1.40.0070.0509.88
5.1.30.0100.05310.50
5.1.20.0100.03010.23
5.1.10.0070.05010.14
5.1.00.0070.05310.08
5.0.50.0070.0478.65
5.0.40.0030.0308.65
5.0.30.0100.0578.65
5.0.20.0000.0508.65
5.0.10.0070.0408.65
5.0.00.0030.0638.65
4.4.90.0070.0308.65
4.4.80.0030.0338.65
4.4.70.0070.0208.65
4.4.60.0030.0338.65
4.4.50.0030.0338.65
4.4.40.0030.0478.65
4.4.30.0000.0338.65
4.4.20.0000.0378.65
4.4.10.0000.0238.65
4.4.00.0000.0378.65
4.3.110.0030.0208.65
4.3.100.0030.0338.65
4.3.90.0000.0338.65
4.3.80.0000.0478.65
4.3.70.0030.0338.65
4.3.60.0030.0278.65
4.3.50.0000.0278.65
4.3.40.0000.0478.65
4.3.30.0000.0408.65
4.3.20.0000.0408.65
4.3.10.0070.0308.65
4.3.00.0000.0278.65

preferences:
52.84 ms | 401 KiB | 5 Q