3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection {} class Link {} class Node { private $label = '_'; private $links; private $attrs; public function __construct($label = '_') { $this -> setLabel($label); } public function getLabel() { return $this -> label; } public function setLabel($label) { if (!is_scalar($label)) { throw new ErrorException("Error Processing Request", 1); } $this -> label = $label; return $this -> getLabel(); } public function __get($name) { if (isset($this -> links -> $name)) { return $this -> links -> $name; } elseif (isset($this -> attrs -> $name)) { return $this -> attrs -> $name; } else { throw new ErrorException("Error Processing Request", 1); } } public function __set($name, $value) { if ($name == '_' && !($value instanceof Node || $value instanceof Link || $value instanceof Collection)) { throw new ErrorException("Error Processing Request", 1); } $name_type = ( (1 * (isset($this -> links -> $name) && count($this -> links -> $name) == 1)) | (2 * (isset($this -> links -> $name) && count($this -> links -> $name) <> 1)) | (3 * isset($this -> attrs -> $name)) | (13 * !(isset($this -> attrs -> $name) || isset($this -> links -> $name))) ); $value_type = ( (5 * ($value instanceof Collection)) | (7 * ($value instanceof Node)) | (17 * ($value instanceof Link)) | (11 * !($value instanceof Node || $value instanceof Link || $value instanceof Collection)) ); switch ($name_type * $value_type) { case 5: case 10: { foreach ($value as $node) { $this -> links -> {$name} -> attach($node); } break; } case 7: case 14: { $this -> links -> {$name} -> attach($value); break; } case 11: case 22: { trigger_error('Converting ' . $name . ' from ' . ((count($this -> links -> $name) <> 1) ? 'Collection' : 'Node') . ' to property', E_USER_WARNING); unset($this -> links -> $name); $this -> attrs -> $name = $value; break; } case 15: { trigger_error('Converting ' . $name . ' from property to Collection', E_USER_WARNING); unset($this -> attrs -> $name); $this -> links -> $name = $value; break; } case 21: { trigger_error('Converting ' . $name . ' from property to Node', E_USER_WARNING); unset($this -> attrs -> $name); $this -> links -> $name = new Collection; $this -> links -> {$name} -> attach($value); break; } case 33: case 143: { $this -> attrs -> $name = $value; break; } case 65: { $this -> links -> $name = $value; break; } case 91: { $this -> links -> $name = new Collection; $this -> links -> {$name} -> attach($value); break; } case 17: case 34: { $this -> links -> {$name} -> attach($value -> getTail()); $this -> links -> {$name} -> attach($value -> getHead()); break; } case 51: { trigger_error('Converting ' . $name . ' from property to Collection', E_USER_WARNING); unset($this -> attrs -> $name); $this -> links -> $name = new Collection; $this -> links -> {$name} -> attach($value -> getTail()); $this -> links -> {$name} -> attach($value -> getHead()); break; } case 221: { $this -> links -> $name = new Collection; $this -> links -> {$name} -> attach($value -> getTail()); $this -> links -> {$name} -> attach($value -> getHead()); break; } default: { throw new ErrorException("Error Processing Request", 1); // no break } } } public function __isset($name) { return (isset($this -> links -> $name) || isset($this -> attrs -> $name)); } public function __unset($name) { unset($this -> links -> $name, $this -> attrs -> $name); } public function serialize() { return serialize(array( 'label' => $this -> getLabel(), 'links' => $this -> links, 'attrs' => $this -> attrs )); } public function unserialize($serialized) { $unserialized = unserialize($serialized); $this -> setLabel($unserialized['label']); $this -> links = $unserialized['links']; $this -> attrs = $unserialized['attrs']; } } $node = new Node; $node->self = $node; echo serialize($node);

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.01416.88
8.3.50.0290.00321.99
8.3.40.0120.00318.71
8.3.30.0120.00319.34
8.3.20.0080.00020.34
8.3.10.0040.00423.64
8.3.00.0040.00420.81
8.2.180.0090.00618.29
8.2.170.0090.00622.96
8.2.160.0090.00622.13
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0030.00526.16
8.2.120.0000.00722.14
8.2.110.0060.00322.08
8.2.100.0060.00617.84
8.2.90.0050.00319.18
8.2.80.0040.00718.05
8.2.70.0030.00617.74
8.2.60.0030.00618.16
8.2.50.0000.00918.07
8.2.40.0000.00818.34
8.2.30.0030.00518.10
8.2.20.0030.00617.75
8.2.10.0000.00819.46
8.2.00.0050.00317.83
8.1.280.0110.00725.92
8.1.270.0080.00023.91
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0090.00023.86
8.1.230.0080.00319.13
8.1.220.0000.00817.78
8.1.210.0030.00618.77
8.1.200.0030.00617.48
8.1.190.0000.00817.64
8.1.180.0040.00418.10
8.1.170.0000.00818.88
8.1.160.0000.00822.09
8.1.150.0080.00018.76
8.1.140.0050.00317.57
8.1.130.0070.00017.95
8.1.120.0040.00417.63
8.1.110.0030.00517.56
8.1.100.0000.00817.61
8.1.90.0000.00817.62
8.1.80.0030.00317.57
8.1.70.0030.00317.51
8.1.60.0000.00917.71
8.1.50.0000.00917.61
8.1.40.0050.00317.54
8.1.30.0000.00817.66
8.1.20.0030.00617.78
8.1.10.0100.00017.71
8.1.00.0000.00817.52
8.0.300.0040.00418.77
8.0.290.0000.00717.28
8.0.280.0000.00818.57
8.0.270.0000.00717.32
8.0.260.0030.00316.96
8.0.250.0000.00717.15
8.0.240.0030.00517.10
8.0.230.0000.00717.22
8.0.220.0000.00717.06
8.0.210.0000.00717.05
8.0.200.0030.00517.00
8.0.190.0050.00517.21
8.0.180.0040.00417.09
8.0.170.0050.00317.02
8.0.160.0030.00517.13
8.0.150.0070.00016.95
8.0.140.0000.00817.07
8.0.130.0060.00013.49
8.0.120.0040.00417.06
8.0.110.0000.00717.09
8.0.100.0070.00017.19
8.0.90.0060.00316.93
8.0.80.0090.00617.03
8.0.70.0040.00416.98
8.0.60.0000.00817.04
8.0.50.0000.00817.15
8.0.30.0090.01117.20
8.0.20.0130.00817.47
8.0.10.0000.00717.09
8.0.00.0100.01016.92
7.4.330.0030.00315.00
7.4.320.0000.00716.54
7.4.300.0030.00316.77
7.4.290.0070.00016.81
7.4.280.0040.00716.42
7.4.270.0070.00016.71
7.4.260.0080.00016.55
7.4.250.0050.00316.59
7.4.240.0020.00516.67
7.4.230.0030.00316.61
7.4.220.0100.01016.79
7.4.210.0040.01216.75
7.4.200.0070.00016.79
7.4.190.0040.00416.77
7.4.160.0100.00816.73
7.4.150.0090.00917.40
7.4.140.0140.00517.86
7.4.130.0070.01316.65
7.4.120.0140.00316.84
7.4.110.0150.00416.75
7.4.100.0080.01216.72
7.4.90.0100.01016.54
7.4.80.0170.00716.77
7.4.70.0180.00316.81
7.4.60.0000.02216.61
7.4.50.0000.00516.55
7.4.40.0040.01122.77
7.4.30.0120.00616.79
7.4.00.0070.01015.08
7.3.330.0030.00313.41
7.3.320.0000.00513.37
7.3.310.0040.00416.59
7.3.300.0030.00316.53
7.3.290.0030.01016.61
7.3.280.0080.01216.55
7.3.270.0150.00917.40
7.3.260.0120.01216.73
7.3.250.0110.00916.46
7.3.240.0040.01416.71
7.3.230.0100.00716.61
7.3.210.0060.01116.55
7.3.200.0150.01019.39
7.3.190.0100.00716.64
7.3.180.0070.01416.49
7.3.170.0080.00816.61
7.3.160.0040.01516.66
7.3.120.0040.01414.88
7.3.10.0090.00416.39
7.3.00.0080.00616.50
7.2.330.0120.00616.58
7.2.320.0140.00516.80
7.2.310.0100.01016.99
7.2.300.0100.00716.86
7.2.290.0060.01516.93
7.2.130.0090.00517.05
7.2.120.0070.00717.04
7.2.110.0090.00516.82
7.2.100.0020.00916.88
7.2.90.0080.00416.82
7.2.80.0080.00716.99
7.2.70.0020.01116.70
7.2.60.0050.01116.82
7.2.50.0020.01116.98
7.2.40.0050.00816.81
7.2.30.0060.00716.89
7.2.20.0080.00516.97
7.2.10.0040.00716.91
7.2.00.0070.00817.79
7.1.250.0060.00715.88
7.1.200.0090.00615.72
7.1.70.0040.00817.09
7.1.60.0030.02219.27
7.1.50.0000.01117.09
7.1.00.0100.07022.24
7.0.200.0000.00816.91
7.0.140.0030.06722.12
7.0.100.0370.06320.07
7.0.90.0330.09319.95
7.0.80.0300.08020.20
7.0.70.0300.08019.97
7.0.60.0170.08319.94
7.0.50.0400.07320.33
7.0.40.0070.08319.96
7.0.30.0170.07720.11
7.0.20.0070.08020.01
7.0.10.0000.08020.03
7.0.00.0070.08720.02
5.6.280.0000.07720.88
5.6.250.0100.08020.61
5.6.240.0070.08320.66
5.6.230.0030.06020.73
5.6.220.0170.07020.60
5.6.210.0130.08020.68
5.6.200.0100.07721.20
5.6.190.0030.09020.96
5.6.180.0100.08321.21
5.6.170.0070.08021.12
5.6.160.0230.07020.97
5.6.150.0070.08321.09
5.6.140.0030.08021.04
5.6.130.0100.08021.13
5.6.120.0130.08321.06
5.6.110.0170.08020.94
5.6.100.0070.08021.08
5.6.90.0030.08021.14
5.6.80.0130.07020.51
5.6.70.0100.07320.48
5.6.60.0030.07320.45
5.6.50.0030.08320.42
5.6.40.0100.08020.54
5.6.30.0130.07720.32
5.6.20.0100.07020.43
5.6.10.0100.08020.54
5.6.00.0030.08720.39
5.5.380.0070.08020.36
5.5.370.0030.08320.36
5.5.360.0070.08720.35
5.5.350.0100.08020.38
5.5.340.0130.07720.80
5.5.330.0100.08020.94
5.5.320.0100.08320.92
5.5.310.0030.08720.94
5.5.300.0100.08320.85
5.5.290.0070.07720.85
5.5.280.0130.08320.80
5.5.270.0070.08020.94
5.5.260.0030.08720.87
5.5.250.0100.08020.66
5.5.240.0130.08020.04
5.5.230.0030.08320.16
5.5.220.0270.07020.28
5.5.210.0070.08020.30
5.5.200.0130.06020.21
5.5.190.0000.08320.01
5.5.180.0000.08320.01
5.5.160.0070.08020.23
5.5.150.0070.08320.19
5.5.140.0170.07020.27
5.5.130.0100.04020.00
5.5.120.0100.07720.25
5.5.110.0070.07720.28
5.5.100.0100.07320.08
5.5.90.0100.07320.17
5.5.80.0070.07019.96
5.5.70.0070.08020.18
5.5.60.0030.08020.12
5.5.50.0070.08020.16
5.5.40.0070.07319.95
5.5.30.0030.08320.07
5.5.20.0130.06720.06
5.5.10.0130.07020.03
5.5.00.0030.08020.05
5.4.450.0230.07019.52
5.4.440.0100.07719.28
5.4.430.0070.06719.45
5.4.420.0030.08019.56
5.4.410.0170.07019.30
5.4.400.0070.07319.17
5.4.390.0030.08719.12
5.4.380.0100.07319.23
5.4.370.0100.07719.05
5.4.360.0100.06019.16
5.4.350.0100.07319.21
5.4.340.0130.07319.09
5.4.320.0030.08019.04
5.4.310.0070.07719.24
5.4.300.0100.06719.03
5.4.290.0130.07718.84
5.4.280.0130.07318.88
5.4.270.0030.07719.12
5.4.260.0070.07318.85
5.4.250.0130.06319.23
5.4.240.0100.06318.94
5.4.230.0070.06719.04
5.4.220.0030.05319.18
5.4.210.0070.08019.07
5.4.200.0100.04019.19
5.4.190.0070.07318.95
5.4.180.0100.04719.11
5.4.170.0100.07019.12
5.4.160.0130.04719.21
5.4.150.0100.08019.16
5.4.140.0230.03716.46
5.4.130.0100.05716.44
5.4.120.0070.05016.46
5.4.110.0030.07316.55
5.4.100.0070.06716.53
5.4.90.0070.07016.45
5.4.80.0070.06716.43
5.4.70.0070.06716.47
5.4.60.0030.06016.36
5.4.50.0100.06716.45
5.4.40.0130.04016.33
5.4.30.0070.07316.54
5.4.20.0070.05316.41
5.4.10.0170.05316.54
5.4.00.0130.06715.91
5.3.290.0100.07714.79
5.3.280.0100.07014.64
5.3.270.0130.07714.80
5.3.260.0100.06314.68
5.3.250.0100.08014.70
5.3.240.0070.08314.77
5.3.230.0070.07314.59
5.3.220.0070.07014.62
5.3.210.0070.06314.70
5.3.200.0030.07314.75
5.3.190.0100.06714.69
5.3.180.0130.07714.70
5.3.170.0170.06314.65
5.3.160.0200.06714.59
5.3.150.0030.05314.69
5.3.140.0130.06714.68
5.3.130.0130.07714.55
5.3.120.0030.08014.64
5.3.110.0130.05714.63
5.3.100.0070.04714.23
5.3.90.0100.04014.21
5.3.80.0070.06314.18
5.3.70.0130.03314.07
5.3.60.0000.07014.09
5.3.50.0030.04313.99
5.3.40.0070.07314.07
5.3.30.0070.07314.02
5.3.20.0000.07713.80
5.3.10.0200.03013.61
5.3.00.0100.06713.62

preferences:
37.74 ms | 401 KiB | 5 Q