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; $obj = cast($destClass, $obj); var_dump($arr, $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.68
8.3.50.0080.00921.21
8.3.40.0110.00818.70
8.3.30.0180.00419.04
8.3.20.0070.00020.29
8.3.10.0080.00022.01
8.3.00.0050.00322.52
8.2.180.0000.01416.63
8.2.170.0120.00322.96
8.2.160.0120.00619.01
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.00726.16
8.2.120.0000.00819.66
8.2.110.0060.00322.21
8.2.100.0060.00619.07
8.2.90.0000.00719.09
8.2.80.0080.00017.97
8.2.70.0040.00417.38
8.2.60.0000.00817.93
8.2.50.0060.00318.07
8.2.40.0060.00318.22
8.2.30.0040.00418.20
8.2.20.0000.00817.71
8.2.10.0040.00417.62
8.2.00.0030.00717.61
8.1.280.0100.01025.92
8.1.270.0040.00422.07
8.1.260.0070.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00323.97
8.1.230.0080.00419.02
8.1.220.0000.00717.74
8.1.210.0050.00318.77
8.1.200.0040.00417.35
8.1.190.0000.00817.53
8.1.180.0040.00420.48
8.1.170.0000.00818.64
8.1.160.0070.00022.17
8.1.150.0040.00418.69
8.1.140.0000.00817.49
8.1.130.0030.00317.87
8.1.120.0050.00317.35
8.1.110.0000.00717.48
8.1.100.0040.00417.42
8.1.90.0000.00717.44
8.1.80.0070.00017.52
8.1.70.0050.00317.46
8.1.60.0080.00017.66
8.1.50.0090.00017.59
8.1.40.0000.00717.44
8.1.30.0000.00717.69
8.1.20.0040.00417.63
8.1.10.0040.00417.53
8.1.00.0030.00617.57
8.0.300.0050.00218.77
8.0.290.0000.00717.18
8.0.280.0040.00218.37
8.0.270.0000.00717.31
8.0.260.0050.00216.86
8.0.250.0070.00016.94
8.0.240.0080.00016.90
8.0.230.0030.00516.89
8.0.220.0000.00716.83
8.0.210.0000.00716.96
8.0.200.0000.00717.02
8.0.190.0030.00617.05
8.0.180.0080.00017.00
8.0.170.0040.00416.84
8.0.160.0040.00416.90
8.0.150.0040.00416.93
8.0.140.0070.00016.83
8.0.130.0030.00313.39
8.0.120.0040.00416.89
8.0.110.0050.00316.93
8.0.100.0070.00016.82
8.0.90.0050.00217.00
8.0.80.0140.00316.91
8.0.70.0040.00416.90
8.0.60.0040.00416.83
8.0.50.0070.00016.84
8.0.30.0130.00617.34
8.0.20.0120.00617.40
8.0.10.0070.00016.84
8.0.00.0080.00916.86
7.4.330.0050.00015.05
7.4.320.0030.00316.67
7.4.300.0000.00616.55
7.4.290.0040.00416.71
7.4.280.0040.00416.66
7.4.270.0030.00316.67
7.4.260.0000.00716.63
7.4.250.0040.00416.52
7.4.240.0030.00416.63
7.4.230.0040.00416.59
7.4.220.0060.01516.67
7.4.210.0120.00716.68
7.4.200.0000.00716.58
7.4.190.0040.00416.62
7.4.160.0150.00916.70
7.4.150.0090.00917.40
7.4.140.0070.01417.86
7.4.130.0120.00816.69
7.4.120.0060.01116.58
7.4.110.0070.01016.52
7.4.100.0100.01316.39
7.4.90.0090.00916.60
7.4.80.0080.01519.39
7.4.70.0040.01216.59
7.4.60.0080.00916.54
7.4.50.0090.00016.36
7.4.40.0120.00622.77
7.4.30.0130.00316.50
7.4.10.0030.01214.84
7.4.00.0150.00215.04
7.3.330.0050.00013.25
7.3.320.0050.00013.18
7.3.310.0030.00316.41
7.3.300.0060.00016.25
7.3.290.0100.01016.30
7.3.280.0070.00816.33
7.3.270.0110.00617.40
7.3.260.0030.01516.77
7.3.250.0070.01016.53
7.3.240.0140.00716.65
7.3.230.0100.01016.41
7.3.210.0130.00316.30
7.3.200.0060.01619.39
7.3.190.0030.01816.42
7.3.180.0090.00616.57
7.3.170.0130.00916.53
7.3.160.0060.00916.23
7.3.130.0100.00715.16
7.3.120.0070.01014.85
7.3.110.0050.00915.11
7.3.100.0110.00514.93
7.3.90.0060.00714.75
7.3.80.0050.00714.92
7.3.70.0050.00914.96
7.3.60.0030.00914.98
7.3.50.0030.01014.98
7.3.40.0050.00714.96
7.3.30.0060.00914.96
7.3.20.0020.01016.74
7.3.10.0070.00816.60
7.3.00.0050.01016.66
7.2.330.0150.00316.63
7.2.320.0110.00716.89
7.2.310.0100.00716.89
7.2.300.0050.01116.48
7.2.290.0030.01516.82
7.2.260.0100.01015.13
7.2.250.0110.00715.33
7.2.240.0060.00915.00
7.2.230.0030.01015.13
7.2.220.0050.00915.07
7.2.210.0070.00914.83
7.2.200.0020.00915.20
7.2.190.0020.01114.93
7.2.180.0050.00815.14
7.2.170.0050.00915.22
7.2.160.0080.00515.15
7.2.150.0050.00717.04
7.2.140.0070.00516.83
7.2.130.0050.01016.79
7.2.120.0070.00816.94
7.2.110.0050.00916.83
7.2.100.0080.00716.79
7.2.90.0070.00716.97
7.2.80.0060.01016.91
7.2.70.0080.00416.95
7.2.60.0040.01016.97
7.2.50.0030.01017.00
7.2.40.0080.00617.05
7.2.30.0060.00716.95
7.2.20.0020.01216.91
7.2.10.0090.00617.05
7.2.00.0030.01017.45
7.1.330.0030.01315.80
7.1.320.0060.00915.83
7.1.310.0060.00815.89
7.1.300.0040.00915.77
7.1.290.0080.00615.60
7.1.280.0050.00915.87
7.1.270.0020.01115.84
7.1.260.0070.00615.56
7.1.250.0080.00615.83
7.1.240.0100.00315.76
7.1.230.0040.00815.95
7.1.220.0090.00315.80
7.1.210.0140.00015.84
7.1.200.0020.00915.63
7.1.190.0030.00715.72
7.1.180.0120.00016.01
7.1.170.0030.00615.96
7.1.160.0090.00015.95
7.1.150.0090.00015.84
7.1.140.0030.00615.69
7.1.130.0040.01115.79
7.1.120.0060.00315.71
7.1.110.0000.00915.90
7.1.100.0020.01217.10
7.1.90.0030.00915.81
7.1.80.0060.00615.58
7.1.70.0080.00516.44
7.1.60.0080.01117.86
7.1.50.0030.00816.16
7.1.40.0060.00615.85
7.1.30.0100.00315.54
7.1.20.0040.01215.79
7.1.10.0060.00615.94
7.1.00.0050.03119.06
7.0.330.0100.00315.48
7.0.320.0000.01215.28
7.0.310.0030.00715.13
7.0.300.0030.00915.22
7.0.290.0130.00315.36
7.0.280.0060.00315.47
7.0.270.0060.00615.37
7.0.260.0060.00615.45
7.0.250.0000.01715.29
7.0.240.0000.01315.61
7.0.230.0040.00415.20
7.0.220.0030.01015.22
7.0.210.0100.00715.45
7.0.200.0050.00816.25
7.0.190.0030.01415.52
7.0.180.0040.00815.34
7.0.170.0150.00015.58
7.0.160.0070.00715.61
7.0.150.0120.00315.38
7.0.140.0040.03818.63
7.0.130.0000.00815.19
7.0.120.0120.00015.54
7.0.110.0040.00715.53
7.0.100.0090.00315.37
7.0.90.0100.04317.78
7.0.80.0040.03617.81
7.0.70.0350.03917.59
7.0.60.0420.02317.68
7.0.50.0300.04517.83
7.0.40.0080.04516.73
7.0.30.0070.04316.80
7.0.20.0020.04616.73
7.0.10.0070.03816.66
7.0.00.0120.04216.79
5.6.400.0080.00314.03
5.6.390.0060.00314.55
5.6.380.0060.00314.59
5.6.370.0070.00314.41
5.6.360.0090.00014.69
5.6.350.0040.01114.13
5.6.340.0060.00614.36
5.6.330.0030.01414.29
5.6.320.0030.01014.16
5.6.310.0140.00014.16
5.6.300.0090.00414.13
5.6.290.0030.01014.33
5.6.280.0050.04017.72
5.6.270.0090.00314.42
5.6.260.0040.00814.16
5.6.250.0070.00714.47
5.6.240.0050.04717.61
5.6.230.0050.03717.51
5.6.220.0110.02617.53
5.6.210.0100.04417.61
5.6.200.0050.04817.76
5.6.190.0030.04917.71
5.6.180.0090.02917.66
5.6.170.0070.04217.68
5.6.160.0080.03417.81
5.6.150.0130.04017.75
5.6.140.0050.03117.68
5.6.130.0050.02218.00
5.6.120.0070.03817.72
5.6.110.0050.04217.79
5.6.100.0130.03817.71
5.6.90.0080.04717.77
5.6.80.0060.03817.23
5.6.70.0040.04417.51
5.6.60.0030.03317.40
5.6.50.0070.04517.53
5.6.40.0060.04117.32
5.6.30.0030.04517.26
5.6.20.0100.02717.39
5.6.10.0090.03817.30
5.6.00.0060.04317.41
5.5.380.0080.04517.43
5.5.370.0070.04017.25
5.5.360.0120.03717.41
5.5.350.0080.02917.40
5.5.340.0150.03517.49
5.5.330.0120.04217.57
5.5.320.0070.04317.74
5.5.310.0030.03117.53
5.5.300.0050.03117.69
5.5.290.0100.02917.60
5.5.280.0020.03417.60
5.5.270.0050.03817.65
5.5.260.0030.03317.50
5.5.250.0040.04717.35
5.5.240.0080.03117.36
5.5.230.0140.03617.21
5.5.220.0110.03317.05
5.5.210.0080.04217.26
5.5.200.0130.02317.29
5.5.190.0120.02817.39
5.5.180.0070.02817.33
5.5.170.0030.00914.36
5.5.160.0100.03916.98
5.5.150.0120.03317.30
5.5.140.0100.03617.13
5.5.130.0030.03217.16
5.5.120.0090.02017.24
5.5.110.0030.02717.16
5.5.100.0050.04617.23
5.5.90.0070.03617.21
5.5.80.0070.04317.16
5.5.70.0070.04017.19
5.5.60.0030.03017.12
5.5.50.0050.04117.26
5.5.40.0030.04017.15
5.5.30.0030.03217.15
5.5.20.0070.04017.08
5.5.10.0030.03817.18
5.5.00.0050.02316.93
5.4.450.0090.03315.62
5.4.440.0020.04515.59
5.4.430.0070.03415.59
5.4.420.0070.03015.60
5.4.410.0100.03515.61
5.4.400.0050.04215.43
5.4.390.0040.04915.43
5.4.380.0110.03615.52
5.4.370.0050.02315.53
5.4.360.0080.03915.44
5.4.350.0040.02715.47
5.4.340.0070.03815.48
5.4.330.0030.00911.82
5.4.320.0000.03715.43
5.4.310.0030.04015.49
5.4.300.0090.03015.43
5.4.290.0060.03515.32
5.4.280.0050.02715.46
5.4.270.0070.02015.36
5.4.260.0000.04215.49
5.4.250.0050.03815.51
5.4.240.0090.03715.50
5.4.230.0100.03515.51
5.4.220.0050.04215.47
5.4.210.0050.03515.45
5.4.200.0050.02115.48
5.4.190.0050.02515.42
5.4.180.0030.03015.37
5.4.170.0020.03515.33
5.4.160.0020.03915.45
5.4.150.0010.02615.37
5.4.140.0030.04414.13
5.4.130.0080.03814.08
5.4.120.0100.03414.12
5.4.110.0020.02714.19
5.4.100.0020.03614.19
5.4.90.0020.02814.16
5.4.80.0100.03614.14
5.4.70.0050.03914.18
5.4.60.0020.03814.12
5.4.50.0030.02514.10
5.4.40.0080.03014.17
5.4.30.0050.03314.06
5.4.20.0070.03914.09
5.4.10.0070.02314.14
5.4.00.0030.02013.81
5.3.290.0020.04313.26
5.3.280.0020.04113.25
5.3.270.0030.02213.26
5.3.260.0080.02813.22
5.3.250.0010.03613.19
5.3.240.0050.02013.19
5.3.230.0030.03613.20
5.3.220.0080.03313.25
5.3.210.0030.03713.25
5.3.200.0050.03513.23
5.3.190.0030.04613.19
5.3.180.0030.04013.18
5.3.170.0040.04113.27
5.3.160.0070.03813.27
5.3.150.0070.02513.26
5.3.140.0030.02313.20
5.3.130.0080.03113.24
5.3.120.0030.02513.20
5.3.110.0050.02213.20
5.3.100.0030.02512.99
5.3.90.0040.03612.96
5.3.80.0020.03212.93
5.3.70.0060.04212.89
5.3.60.0050.03412.94
5.3.50.0010.04012.93
5.3.40.0050.02112.95
5.3.30.0030.02312.94
5.3.20.0000.02812.78
5.3.10.0050.03112.82
5.3.00.0050.03512.70
5.2.170.0070.05711.06
5.2.160.0070.06311.22
5.2.150.0170.05311.20
5.2.140.0100.05711.20
5.2.130.0100.02310.99
5.2.120.0030.05311.17
5.2.110.0070.05711.13
5.2.100.0070.05711.02
5.2.90.0070.05711.17
5.2.80.0070.04310.96
5.2.70.0030.03011.11
5.2.60.0030.03011.06
5.2.50.0070.03010.92
5.2.40.0030.05011.12
5.2.30.0130.05311.01
5.2.20.0000.05310.97
5.2.10.0000.05310.97
5.2.00.0000.06310.64
5.1.60.0030.05310.00
5.1.50.0070.05010.00
5.1.40.0000.03310.05
5.1.30.0030.06010.21
5.1.20.0030.06010.50
5.1.10.0070.05010.07
5.1.00.0000.05710.08
5.0.50.0000.0379.72
5.0.40.0070.0439.72
5.0.30.0000.0709.72
5.0.20.0030.0439.72
5.0.10.0130.0409.72
5.0.00.0000.0679.72
4.4.90.0030.0339.72
4.4.80.0000.0379.72
4.4.70.0000.0379.72
4.4.60.0030.0339.72
4.4.50.0030.0309.72
4.4.40.0000.0509.72
4.4.30.0030.0239.72
4.4.20.0030.0339.72
4.4.10.0030.0379.72
4.4.00.0030.0539.72
4.3.110.0030.0379.72
4.3.100.0000.0379.72
4.3.90.0070.0179.72
4.3.80.0000.0579.72
4.3.70.0030.0379.72
4.3.60.0030.0339.72
4.3.50.0030.0339.72
4.3.40.0030.0509.72
4.3.30.0000.0339.72
4.3.20.0000.0339.72
4.3.10.0030.0339.72
4.3.00.0030.0339.72

preferences:
58.43 ms | 401 KiB | 5 Q