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; var_dump($arr); //$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.0070.01318.43
8.3.50.0110.00816.38
8.3.40.0110.00819.02
8.3.30.0110.00319.18
8.3.20.0060.00320.27
8.3.10.0040.00422.05
8.3.00.0030.00522.44
8.2.180.0120.00316.50
8.2.170.0120.00622.96
8.2.160.0140.00019.34
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0180.00026.16
8.2.120.0050.00319.66
8.2.110.0030.00622.24
8.2.100.0040.00719.34
8.2.90.0030.00619.08
8.2.80.0040.00417.97
8.2.70.0080.00017.63
8.2.60.0000.00917.77
8.2.50.0030.00618.07
8.2.40.0160.00017.81
8.2.30.0000.00718.03
8.2.20.0030.00517.76
8.2.10.0040.00417.90
8.2.00.0050.00517.68
8.1.270.0040.00422.06
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0050.00523.61
8.1.230.0040.00819.16
8.1.220.0030.00517.74
8.1.210.0050.00318.77
8.1.200.0060.00317.48
8.1.190.0060.00317.65
8.1.180.0000.00920.40
8.1.170.0000.00818.72
8.1.160.0080.00022.22
8.1.150.0040.00418.61
8.1.140.0050.00317.40
8.1.130.0000.00817.80
8.1.120.0040.00417.52
8.1.110.0000.00717.52
8.1.100.0070.00017.38
8.1.90.0030.00317.46
8.1.80.0040.00417.54
8.1.70.0030.00317.39
8.1.60.0030.00517.61
8.1.50.0080.00017.52
8.1.40.0000.00817.43
8.1.30.0000.00817.66
8.1.20.0040.00417.75
8.1.10.0030.00617.61
8.1.00.0030.00617.57
8.0.300.0020.00518.77
8.0.290.0040.00417.05
8.0.280.0000.00718.43
8.0.270.0050.00217.23
8.0.260.0000.00716.75
8.0.250.0000.00916.94
8.0.240.0030.00516.98
8.0.230.0000.00716.92
8.0.220.0070.00016.95
8.0.210.0030.00316.98
8.0.200.0030.00316.98
8.0.190.0030.00517.03
8.0.180.0040.00416.94
8.0.170.0030.00517.00
8.0.160.0080.00017.00
8.0.150.0000.00716.77
8.0.140.0040.00416.99
8.0.130.0000.00613.43
8.0.120.0070.00016.94
8.0.110.0000.00716.93
8.0.100.0050.00216.81
8.0.90.0000.00816.95
8.0.80.0130.00317.05
8.0.70.0040.00417.13
8.0.60.0050.00317.11
8.0.50.0000.00817.11
8.0.30.0130.00716.94
8.0.20.0140.00517.40
8.0.10.0000.00716.96
8.0.00.0080.00816.74
7.4.330.0000.00515.11
7.4.320.0030.00316.54
7.4.300.0000.00616.63
7.4.290.0030.00516.66
7.4.280.0040.00416.68
7.4.270.0080.00016.55
7.4.260.0070.00016.64
7.4.250.0080.00016.62
7.4.240.0010.00616.55
7.4.230.0000.00616.34
7.4.220.0110.00616.66
7.4.210.0080.01116.70
7.4.200.0000.00816.62
7.4.190.0070.00016.64
7.4.160.0150.00916.48
7.4.150.0070.01017.40
7.4.140.0090.00917.86
7.4.130.0110.01116.46
7.4.120.0070.01016.58
7.4.110.0090.01016.57
7.4.100.0100.01316.53
7.4.90.0080.00816.45
7.4.80.0160.00619.39
7.4.70.0110.00816.55
7.4.60.0060.00916.49
7.4.50.0000.00916.68
7.4.40.0030.01322.77
7.4.30.0080.00816.62
7.4.00.0040.01414.90
7.3.330.0050.00013.30
7.3.320.0060.00013.43
7.3.310.0030.00316.43
7.3.300.0000.00716.39
7.3.290.0070.00716.47
7.3.280.0100.00616.38
7.3.270.0100.00717.40
7.3.260.0050.01416.52
7.3.250.0110.00716.45
7.3.240.0170.00016.39
7.3.230.0070.01116.39
7.3.210.0060.01116.44
7.3.200.0080.01319.39
7.3.190.0040.01716.49
7.3.180.0040.01516.46
7.3.170.0090.00916.52
7.3.160.0150.00016.44
7.3.120.0000.01714.73
7.2.330.0090.01216.92
7.2.320.0150.00316.84
7.2.310.0100.00716.70
7.2.300.0100.00716.51
7.2.290.0060.01016.79
7.2.60.0030.01016.57
7.2.00.0060.00619.42
7.1.200.0100.00315.66
7.1.100.0040.00817.87
7.1.70.0000.00817.17
7.1.60.0130.01319.82
7.1.50.0100.00716.90
7.1.00.0070.03322.30
7.0.200.0230.00514.54
7.0.140.0000.07022.21
7.0.90.0670.08019.94
7.0.80.0600.08019.89
7.0.70.0670.07719.98
7.0.60.0630.06720.05
7.0.50.0630.08320.32
7.0.40.0070.04020.13
7.0.30.0100.06020.04
7.0.20.0070.06020.14
7.0.10.0130.08020.03
7.0.00.0030.04720.04
5.6.280.0070.07021.04
5.6.240.0030.08320.46
5.6.230.0130.07320.71
5.6.220.0100.08720.54
5.6.210.0130.07720.72
5.6.200.0030.04721.04
5.6.190.0100.05721.12
5.6.180.0030.04321.02
5.6.170.0170.06721.03
5.6.160.0030.07320.98
5.6.150.0170.07321.04
5.6.140.0100.06020.99
5.6.130.0130.07721.00
5.6.120.0130.07321.18
5.6.110.0130.05720.89
5.6.100.0130.04721.02
5.6.90.0170.07321.03
5.6.80.0130.07320.57
5.6.70.0100.08020.41
5.6.60.0130.04720.43
5.6.50.0100.07320.36
5.6.40.0100.07720.43
5.6.30.0070.07320.37
5.6.20.0070.08020.41
5.6.10.0030.06020.41
5.6.00.0030.04020.44
5.5.380.0070.04320.29
5.5.370.0100.08320.31
5.5.360.0070.04320.45
5.5.350.0070.08320.39
5.5.340.0030.05720.80
5.5.330.0100.06320.89
5.5.320.0100.03720.75
5.5.310.0070.07020.70
5.5.300.0100.03720.91
5.5.290.0070.07720.90
5.5.280.0070.08320.92
5.5.270.0100.07720.88
5.5.260.0070.08720.93
5.5.250.0000.08720.69
5.5.240.0000.05720.29
5.5.230.0070.06320.20
5.5.220.0100.06020.28
5.5.210.0200.05020.15
5.5.200.0130.06320.20
5.5.190.0130.07020.09
5.5.180.0070.08320.27
5.5.160.0000.06020.10
5.5.150.0000.09320.12
5.5.140.0000.08320.29
5.5.130.0070.08020.25
5.5.120.0170.07720.12
5.5.110.0100.05020.26
5.5.100.0130.05320.08
5.5.90.0030.06020.18
5.5.80.0100.07020.11
5.5.70.0130.07020.07
5.5.60.0130.07320.10
5.5.50.0070.08020.02
5.5.40.0070.08020.13
5.5.30.0030.04720.07
5.5.20.0270.06320.02
5.5.10.0130.04320.07
5.5.00.0130.03720.09
5.4.450.0000.04719.36
5.4.440.0070.06719.42
5.4.430.0100.07719.41
5.4.420.0070.08319.41
5.4.410.0000.08319.23
5.4.400.0070.08019.25
5.4.390.0000.08319.05
5.4.380.0130.06019.21
5.4.370.0070.08019.12
5.4.360.0100.08018.85
5.4.350.0030.08019.20
5.4.340.0070.07719.05
5.4.320.0170.07319.13
5.4.310.0100.07319.03
5.4.300.0100.07718.87
5.4.290.0130.06318.94
5.4.280.0170.05019.12
5.4.270.0030.07718.89
5.4.260.0030.04019.00
5.4.250.0030.04718.87
5.4.240.0030.08719.21
5.4.230.0030.03718.87
5.4.220.0230.07319.21
5.4.210.0100.05718.92
5.4.200.0100.07019.12
5.4.190.0030.08019.19
5.4.180.0100.05719.22
5.4.170.0170.07319.11
5.4.160.0130.07319.07
5.4.150.0000.06319.10
5.4.140.0030.04716.46
5.4.130.0000.04716.35
5.4.120.0000.06316.45
5.4.110.0030.05716.53
5.4.100.0100.07016.49
5.4.90.0000.05016.56
5.4.80.0100.06716.54
5.4.70.0030.03716.52
5.4.60.0100.04716.40
5.4.50.0070.06716.34
5.4.40.0030.06016.43
5.4.30.0200.05716.39
5.4.20.0070.04316.39
5.4.10.0100.03716.48
5.4.00.0070.05015.82
5.3.290.0070.07314.79
5.3.280.0070.07014.73
5.3.270.0070.05314.57
5.3.260.0070.04714.68
5.3.250.0070.07314.68
5.3.240.0100.04714.76
5.3.230.0100.07314.63
5.3.220.0030.04014.50
5.3.210.0170.04714.60
5.3.200.0100.07314.51
5.3.190.0000.05014.65
5.3.180.0100.03714.61
5.3.170.0070.07714.60
5.3.160.0030.04014.64
5.3.150.0100.04314.50
5.3.140.0070.07314.49
5.3.130.0070.05014.58
5.3.120.0100.06014.67
5.3.110.0070.04314.60
5.3.100.0030.04314.08
5.3.90.0100.07314.10
5.3.80.0000.06714.06
5.3.70.0130.04714.05
5.3.60.0030.07713.99
5.3.50.0070.07014.05
5.3.40.0130.06713.89
5.3.30.0100.05313.91
5.3.20.0000.05713.78
5.3.10.0030.07313.61
5.3.00.0100.06713.64
5.2.170.0030.05711.21
5.2.160.0070.06311.20
5.2.150.0100.04311.26
5.2.140.0070.06011.21
5.2.130.0100.05711.18
5.2.120.0100.05311.22
5.2.110.0070.05011.02
5.2.100.0070.05711.16
5.2.90.0000.07011.04
5.2.80.0000.06311.24
5.2.70.0130.05711.13
5.2.60.0030.05711.12
5.2.50.0000.03710.89
5.2.40.0030.03010.92
5.2.30.0100.05010.89
5.2.20.0100.05311.00
5.2.10.0070.02710.81
5.2.00.0070.02710.59
5.1.60.0030.04010.54
5.1.50.0030.02310.54
5.1.40.0030.02710.54
5.1.30.0030.02710.54
5.1.20.0030.02710.54
5.1.10.0000.02710.54
5.1.00.0070.02310.54
5.0.50.0070.01310.54
5.0.40.0070.01310.54
5.0.30.0000.03010.54
5.0.20.0030.01310.54
5.0.10.0070.02710.54
5.0.00.0000.03010.54
4.4.90.0030.03310.54
4.4.80.0000.02310.54
4.4.70.0000.01710.54
4.4.60.0000.01710.54
4.4.50.0000.01710.54
4.4.40.0000.02710.54
4.4.30.0000.01710.54
4.4.20.0030.01310.54
4.4.10.0000.01710.54
4.4.00.0030.02310.54
4.3.110.0030.01710.54
4.3.100.0030.01310.54
4.3.90.0030.01310.54
4.3.80.0000.02310.54
4.3.70.0000.01310.54
4.3.60.0000.01310.54
4.3.50.0000.01710.54
4.3.40.0000.03710.54
4.3.30.0000.02310.54
4.3.20.0000.03710.54
4.3.10.0030.03310.54
4.3.00.0000.01710.54

preferences:
54.39 ms | 400 KiB | 5 Q