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) { $sourceObj = $obj; $obj = function(){ echo 'hello'; }; //$reflectionClass = new ReflectionClass($obj); //var_dump($reflectionClass); $arr = (array) $obj; $obj = (object) $arr; $obj = cast($sourceObj, $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.70.0120.00918.31
8.3.60.0040.01518.68
8.3.50.0130.00921.09
8.3.40.0090.00918.66
8.3.30.0070.01119.14
8.3.20.0040.00420.19
8.3.10.0080.00021.92
8.3.00.0050.00322.46
8.2.190.0120.00616.58
8.2.180.0040.01116.88
8.2.170.0140.00422.96
8.2.160.0100.00320.43
8.2.150.0070.00024.18
8.2.140.0050.00324.66
8.2.130.0070.00726.16
8.2.120.0000.00919.54
8.2.110.0000.01022.20
8.2.100.0080.00419.25
8.2.90.0030.00519.21
8.2.80.0050.00317.97
8.2.70.0090.00017.63
8.2.60.0080.00018.03
8.2.50.0060.00318.07
8.2.40.0030.00618.28
8.2.30.0040.00418.18
8.2.20.0040.00417.61
8.2.10.0030.00617.73
8.2.00.0040.00417.77
8.1.280.0110.00325.92
8.1.270.0080.00022.06
8.1.260.0050.00226.35
8.1.250.0050.00328.09
8.1.240.0060.00323.84
8.1.230.0040.00819.15
8.1.220.0030.00517.76
8.1.210.0000.00818.77
8.1.200.0030.00717.23
8.1.190.0000.00817.55
8.1.180.0000.00820.40
8.1.170.0060.00318.61
8.1.160.0000.00822.18
8.1.150.0030.00618.61
8.1.140.0040.00417.48
8.1.130.0030.00317.86
8.1.120.0040.00417.46
8.1.110.0050.00217.46
8.1.100.0030.00417.53
8.1.90.0000.00717.49
8.1.80.0000.00717.48
8.1.70.0030.00317.51
8.1.60.0030.00617.46
8.1.50.0040.00417.58
8.1.40.0040.00417.45
8.1.30.0000.00817.52
8.1.20.0000.00817.67
8.1.10.0080.00017.65
8.1.00.0000.00817.56
8.0.300.0000.00718.77
8.0.290.0040.00416.93
8.0.280.0000.00718.51
8.0.270.0000.00717.35
8.0.260.0030.00316.85
8.0.250.0000.00716.93
8.0.240.0000.00816.88
8.0.230.0000.00716.90
8.0.220.0030.00316.82
8.0.210.0040.00416.82
8.0.200.0030.00317.01
8.0.190.0000.00816.88
8.0.180.0000.00717.01
8.0.170.0040.00416.86
8.0.160.0040.00416.86
8.0.150.0040.00416.95
8.0.140.0040.00416.87
8.0.130.0000.00913.25
8.0.120.0020.00516.89
8.0.110.0040.00416.82
8.0.100.0040.00416.89
8.0.90.0050.00216.91
8.0.80.0030.01216.89
8.0.70.0000.00716.79
8.0.60.0030.00516.84
8.0.50.0070.00016.75
8.0.30.0120.01017.13
8.0.20.0140.00517.40
8.0.10.0030.00517.01
8.0.00.0070.01316.84
7.4.330.0030.00316.81
7.4.320.0030.00316.62
7.4.300.0000.00616.54
7.4.290.0000.00716.43
7.4.280.0070.00016.52
7.4.270.0000.00616.62
7.4.260.0000.00716.59
7.4.250.0040.00416.58
7.4.240.0030.00516.59
7.4.230.0030.00316.54
7.4.220.0090.00616.64
7.4.210.0060.01016.61
7.4.200.0000.00716.52
7.4.190.0050.00316.80
7.4.160.0040.01316.61
7.4.150.0100.00717.40
7.4.140.0110.01117.86
7.4.130.0110.01116.56
7.4.120.0040.01216.50
7.4.110.0090.00916.52
7.4.100.0110.00716.51
7.4.90.0100.00716.66
7.4.80.0120.01219.39
7.4.70.0040.01316.59
7.4.60.0100.00716.46
7.4.50.0030.00616.60
7.4.40.0100.00722.77
7.4.30.0120.01016.58
7.4.10.0120.00614.83
7.4.00.0070.01014.94
7.3.330.0000.00613.31
7.3.320.0000.00613.38
7.3.310.0040.00416.39
7.3.300.0070.00016.23
7.3.290.0070.01316.39
7.3.280.0070.00816.37
7.3.270.0120.00617.40
7.3.260.0060.01216.44
7.3.250.0070.01016.44
7.3.240.0090.00916.43
7.3.230.0060.01016.57
7.3.210.0100.00716.37
7.3.200.0120.00919.39
7.3.190.0140.00716.54
7.3.180.0080.00816.48
7.3.170.0080.00816.68
7.3.160.0120.00316.51
7.3.130.0030.01614.21
7.3.120.0070.01014.61
7.3.110.0130.00614.88
7.3.100.0000.01415.09
7.3.90.0060.00614.57
7.3.80.0000.01614.87
7.3.70.0110.00414.80
7.3.60.0090.00614.82
7.3.50.0120.00314.91
7.3.40.0040.00714.60
7.3.30.0090.00614.84
7.3.20.0050.00516.84
7.3.10.0070.00916.42
7.3.00.0070.00916.60
7.2.330.0060.01216.84
7.2.320.0060.01516.75
7.2.310.0100.01316.74
7.2.300.0070.01316.52
7.2.290.0000.01616.68
7.2.260.0060.01215.04
7.2.250.0030.01714.77
7.2.240.0030.01214.98
7.2.230.0030.01315.07
7.2.220.0030.01315.07
7.2.210.0000.01415.36
7.2.200.0060.00915.09
7.2.190.0000.01315.13
7.2.180.0120.00614.96
7.2.170.0090.00614.84
7.2.160.0000.01115.04
7.2.150.0000.01417.02
7.2.140.0110.00417.07
7.2.130.0070.00816.77
7.2.120.0060.01416.74
7.2.110.0100.00716.80
7.2.100.0120.00616.77
7.2.90.0140.00716.92
7.2.80.0120.00516.78
7.2.70.0100.00816.69
7.2.60.0090.00616.74
7.2.50.0120.00616.50
7.2.40.0060.01116.90
7.2.30.0090.00316.84
7.2.20.0030.01016.70
7.2.10.0090.00916.89
7.2.00.0080.00917.51
7.1.330.0000.01515.52
7.1.320.0120.00315.64
7.1.310.0060.01215.79
7.1.300.0040.01115.94
7.1.290.0100.00715.76
7.1.280.0070.00715.78
7.1.270.0040.00715.48
7.1.260.0090.00615.57
7.1.250.0080.00815.47
7.1.240.0070.00315.62
7.1.230.0080.00815.88
7.1.220.0080.00315.73
7.1.210.0130.00315.75
7.1.200.0030.01215.80
7.1.190.0030.01215.53
7.1.180.0030.01015.84
7.1.170.0070.01015.89
7.1.160.0060.00315.45
7.1.150.0030.01015.73
7.1.140.0060.00916.04
7.1.130.0030.00615.63
7.1.120.0120.00015.88
7.1.110.0030.01015.47
7.1.100.0080.00316.84
7.1.90.0000.01415.59
7.1.80.0110.00315.92
7.1.70.0060.00816.19
7.1.60.0040.01517.81
7.1.50.0050.00916.17
7.1.40.0000.01416.00
7.1.30.0080.00015.48
7.1.20.0040.00815.46
7.1.10.0070.01115.72
7.1.00.0060.02019.01
7.0.330.0070.00715.39
7.0.320.0090.00015.29
7.0.310.0150.00315.19
7.0.300.0080.00315.35
7.0.290.0060.00615.06
7.0.280.0060.00615.09
7.0.270.0060.00315.38
7.0.260.0040.01115.03
7.0.250.0040.00715.41
7.0.240.0040.00415.57
7.0.230.0070.00415.42
7.0.220.0060.00915.61
7.0.210.0030.01015.14
7.0.200.0010.00716.05
7.0.190.0070.00315.32
7.0.180.0080.00315.15
7.0.170.0060.00615.30
7.0.160.0130.00015.40
7.0.150.0030.01315.35
7.0.140.0120.03718.79
7.0.130.0040.00815.44
7.0.120.0140.00015.40
7.0.110.0060.00615.57
7.0.100.0000.01315.48
7.0.90.0150.02317.71
7.0.80.0150.03317.74
7.0.70.0220.02517.55
7.0.60.0210.01717.67
7.0.50.0320.03517.85
7.0.40.0070.02516.74
7.0.30.0050.04516.77
7.0.20.0080.04016.85
7.0.10.0100.04516.67
7.0.00.0070.02316.72
5.6.400.0110.00314.35
5.6.390.0080.00014.33
5.6.380.0110.00014.59
5.6.370.0030.00914.58
5.6.360.0060.00914.18
5.6.350.0070.00714.11
5.6.340.0030.01014.56
5.6.330.0060.00314.58
5.6.320.0030.00714.12
5.6.310.0100.00014.28
5.6.300.0110.00414.13
5.6.290.0040.00714.32
5.6.280.0090.00314.48
5.6.270.0100.00714.09
5.6.260.0070.01014.29
5.6.250.0040.00714.34
5.6.240.0060.03317.52
5.6.230.0060.02417.20
5.6.220.0060.02517.49
5.6.210.0090.02717.35
5.6.200.0110.04017.60
5.6.190.0140.03517.64
5.6.180.0060.04717.54
5.6.170.0080.04617.61
5.6.160.0020.05017.63
5.6.150.0050.04617.56
5.6.140.0050.03017.66
5.6.130.0080.03217.63
5.6.120.0100.02717.62
5.6.110.0020.03517.63
5.6.100.0080.03817.55
5.6.90.0050.03117.69
5.6.80.0080.02817.34
5.6.70.0100.02917.34
5.6.60.0050.04517.40
5.6.50.0100.04217.33
5.6.40.0080.02617.06
5.6.30.0050.02617.37
5.6.20.0050.04717.28
5.6.10.0130.02817.30
5.6.00.0070.04017.22
5.5.380.0100.02317.36
5.5.370.0030.03317.39
5.5.360.0050.02417.45
5.5.350.0070.03017.20
5.5.340.0040.03017.70
5.5.330.0070.04717.64
5.5.320.0120.03817.63
5.5.310.0110.03017.45
5.5.300.0100.03817.54
5.5.290.0060.04317.52
5.5.280.0050.02517.58
5.5.270.0100.03617.63
5.5.260.0080.02817.62
5.5.250.0080.04317.44
5.5.240.0070.04217.28
5.5.230.0020.04117.14
5.5.220.0050.04717.24
5.5.210.0130.03117.12
5.5.200.0020.02717.17
5.5.190.0050.02717.16
5.5.180.0080.02817.19
5.5.170.0040.01114.31
5.5.160.0050.04517.31
5.5.150.0070.04117.16
5.5.140.0080.02817.31
5.5.130.0030.04217.02
5.5.120.0100.04017.34
5.5.110.0080.03517.29
5.5.100.0030.04517.18
5.5.90.0090.03517.28
5.5.80.0080.03717.22
5.5.70.0080.02317.19
5.5.60.0080.02617.10
5.5.50.0090.03817.19
5.5.40.0050.02317.05
5.5.30.0100.03217.15
5.5.20.0070.04016.94
5.5.10.0110.02317.15
5.5.00.0050.03017.00
5.4.450.0070.04515.37
5.4.440.0020.04615.08
5.4.430.0150.03615.24
5.4.420.0050.02215.24
5.4.410.0090.03515.14
5.4.400.0050.02314.95
5.4.390.0030.04315.07
5.4.380.0080.03115.17
5.4.370.0100.03314.82
5.4.360.0040.03514.95
5.4.350.0050.03615.08
5.4.340.0070.02515.03
5.4.330.0040.00810.90
5.4.320.0050.04714.89
5.4.310.0040.03515.06
5.4.300.0070.04015.09
5.4.290.0080.03715.08
5.4.280.0060.02115.00
5.4.270.0150.03615.07
5.4.260.0070.03715.00
5.4.250.0060.04014.83
5.4.240.0090.02315.00
5.4.230.0050.02315.07
5.4.220.0020.03415.09
5.4.210.0020.02514.89
5.4.200.0010.02415.01
5.4.190.0050.04015.22
5.4.180.0070.04315.23
5.4.170.0090.02015.05
5.4.160.0070.04015.12
5.4.150.0060.03215.02
5.4.140.0030.03813.69
5.4.130.0050.02413.81
5.4.120.0080.02113.70
5.4.110.0080.02513.75
5.4.100.0040.03913.64
5.4.90.0060.02013.71
5.4.80.0070.04213.74
5.4.70.0050.03813.80
5.4.60.0090.03813.65
5.4.50.0070.03213.71
5.4.40.0050.03913.62
5.4.30.0070.04013.74
5.4.20.0060.03813.75
5.4.10.0100.03413.77
5.4.00.0050.03713.43
5.3.290.0020.04612.61
5.3.280.0040.02812.55
5.3.270.0030.02512.64
5.3.260.0050.04212.57
5.3.250.0080.03112.59
5.3.240.0030.04212.45
5.3.230.0080.03912.61
5.3.220.0050.02812.61
5.3.210.0020.04012.54
5.3.200.0030.03712.53
5.3.190.0120.03212.46
5.3.180.0100.03912.59
5.3.170.0020.03712.52
5.3.160.0070.02712.55
5.3.150.0030.02312.72
5.3.140.0050.03312.59
5.3.130.0090.03712.49
5.3.120.0050.03912.58
5.3.110.0090.02912.58
5.3.100.0030.02412.21
5.3.90.0120.03812.32
5.3.80.0040.02412.25
5.3.70.0050.03912.17
5.3.60.0070.04112.31
5.3.50.0070.04312.28
5.3.40.0030.04312.30
5.3.30.0050.04012.17
5.3.20.0060.02911.93
5.3.10.0020.04311.94
5.3.00.0090.02112.05
5.2.170.0100.03711.06
5.2.160.0070.05311.01
5.2.150.0000.07011.24
5.2.140.0070.05711.00
5.2.130.0070.05011.24
5.2.120.0070.05311.11
5.2.110.0030.05711.16
5.2.100.0030.06011.16
5.2.90.0070.05711.17
5.2.80.0030.04711.22
5.2.70.0100.04711.22
5.2.60.0070.06010.97
5.2.50.0070.05711.13
5.2.40.0000.04710.91
5.2.30.0100.05710.97
5.2.20.0000.06010.80
5.2.10.0070.04710.98
5.2.00.0070.06010.64
5.1.60.0030.03310.02
5.1.50.0100.0439.86
5.1.40.0000.05710.11
5.1.30.0070.05710.36
5.1.20.0070.03710.39
5.1.10.0100.05010.17
5.1.00.0030.05710.08
5.0.50.0000.0408.61
5.0.40.0100.0338.53
5.0.30.0030.0608.24
5.0.20.0030.0408.30
5.0.10.0000.0408.19
5.0.00.0070.0478.25
4.4.90.0100.0306.93
4.4.80.0030.0236.93
4.4.70.0000.0406.93
4.4.60.0030.0336.93
4.4.50.0000.0306.93
4.4.40.0030.0536.93
4.4.30.0030.0336.93
4.4.20.0030.0276.93
4.4.10.0030.0336.93
4.4.00.0030.0476.93
4.3.110.0030.0376.93
4.3.100.0030.0336.93
4.3.90.0000.0376.93
4.3.80.0030.0476.93
4.3.70.0070.0306.93
4.3.60.0070.0236.93
4.3.50.0000.0376.93
4.3.40.0000.0536.93
4.3.30.0000.0376.93
4.3.20.0000.0306.93
4.3.10.0100.0236.93
4.3.00.0000.0276.93

preferences:
45.21 ms | 401 KiB | 5 Q