3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Thing { public function __construct( public readonly string $name, public readonly ?Thing $left = null, public readonly ?Thing $right = null, ) { } public function hasThings(): bool { return $this->left || $this->right; } public function getThingDepth(): int{ if(!$this->hasThings()) { return 1; } return max($this->left->getThingDepth(), $this->right->getThingDepth()) + 1; } public function getHtml(): string { $buf = []; $buf[] = '<table>'; $buf[] = '<tr>'; $buf[] = '<td>'; $buf[] = $this->name; $buf[] = '</td>'; if($this->hasThings()){ $buf[] = '<td>'; $buf[] = $this?->left->getHtml() ?? '-'; $buf[] = $this?->right->getHtml() ?? '-'; $buf[] = '</td>'; } $buf[] = '</tr>'; $buf[] = '</table>'; return implode("\n", $buf); } } $me = new Thing( 'Child', new Thing('Dad', new Thing('Dad\'s dad'), new Thing('Dad\'s mom')), new Thing('Mom', new Thing('Mom\'s dad'), new Thing('Mom\'s mom')), ); echo $me->getHtml();

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.5.10.0120.00620.27
8.5.00.0140.00820.09
8.4.160.0060.00424.05
8.4.150.0060.00716.91
8.4.140.0150.00717.73
8.4.130.0140.00817.79
8.4.120.0130.00724.27
8.4.110.0120.00519.10
8.4.100.0090.01218.70
8.4.90.0110.00920.70
8.4.80.0050.00418.98
8.4.70.0090.00720.75
8.4.60.0120.00818.82
8.4.50.0080.01020.54
8.4.40.0070.01019.40
8.4.30.0060.01318.56
8.4.20.0090.00019.55
8.4.10.0090.00622.21
8.3.280.0020.00014.05
8.3.270.0110.00916.71
8.3.260.0130.00616.77
8.3.250.0070.00417.18
8.3.240.0130.00717.33
8.3.230.0120.00916.57
8.3.220.0130.00618.88
8.3.210.0120.00318.38
8.3.200.0050.00416.60
8.3.190.0150.00417.41
8.3.180.0100.00919.25
8.3.170.0090.00916.70
8.3.160.0090.00917.11
8.3.150.0060.00317.22
8.3.140.0140.00420.94
8.3.130.0040.00418.26
8.3.120.0030.01219.17
8.3.110.0060.01216.71
8.3.100.0110.00416.78
8.3.50.0040.00416.63
8.2.290.0090.01120.48
8.2.280.0110.00818.24
8.2.270.0100.01018.65
8.2.260.0000.00816.69
8.2.250.0040.00418.39
8.2.240.0030.00617.07
8.2.230.0040.00418.25
8.2.220.0100.01016.45
8.2.30.0050.00318.90
8.1.330.0050.00521.96
8.1.320.0110.00916.16
8.1.310.0030.00617.96
8.1.300.0090.00018.33

preferences:
31.49 ms | 403 KiB | 5 Q