3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class User { private const STATUS_ACTIVE = 'active'; private const STATUS_INACTIVE = 'inactive'; public function __construct(private string $username, private string $status = self::STATUS_ACTIVE) { } private function setStatus(string $status): void { assert( in_array($status, [self::STATUS_ACTIVE, self::STATUS_INACTIVE]), sprintf('Le status %s n\'est pas valide. Les status possibles sont : %s', $status, implode(', ', [self::STATUS_ACTIVE, self::STATUS_INACTIVE])) ); $this->status = $status; } private function getStatus(): string { return $this->status; } } class Admin extends User { public const STATUS_LOCKED = 'locked'; // la méthode est entièrement ré-écrite ici :) seule la signature reste inchangée public function setStatus(string $status): void { assert( in_array($status, [self::STATUS_ACTIVE, self::STATUS_INACTIVE, self::STATUS_LOCKED]), sprintf('Le status %s n\'est pas valide. Les status possibles sont : %s', $status, implode(', ', [self::STATUS_ACTIVE, self::STATUS_INACTIVE, self::STATUS_LOCKED])) ); $this->status = $status; } // la méthode utilise celle de la classe parente, et ajoute un comportement :) public function getStatus(): string { return strtoupper(parent::getStatus()); } } $admin = new Admin('Paddington'); $admin->setStatus(Admin::STATUS_LOCKED); echo $admin->getStatus();

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.4.20.0080.00019.04
8.4.10.0060.00317.83
8.3.150.0070.01117.31
8.3.140.0110.00517.33
8.3.130.0210.01017.12
8.3.120.0190.00517.21
8.3.110.0140.00617.56
8.3.100.0210.00522.73
8.3.90.0160.00718.68
8.3.80.0140.01016.58
8.3.70.0180.00816.65
8.3.60.0220.00416.66
8.3.50.0180.00716.60
8.3.40.0160.00817.81
8.3.30.0130.00617.72
8.3.20.0110.00619.52
8.3.10.0140.00619.73
8.3.00.0120.00619.49
8.2.260.0170.00216.44
8.2.250.0150.00617.26
8.2.240.0170.00417.18
8.2.230.0150.00317.91
8.2.220.0150.00520.71
8.2.210.0150.00318.69
8.2.200.0140.00516.63
8.2.190.0150.00516.48
8.2.180.0180.00518.41
8.2.170.0160.00817.86
8.2.160.0180.00318.69
8.2.150.0140.00619.38
8.2.140.0130.00619.37
8.2.130.0140.00519.66
8.2.120.0150.00718.72
8.2.110.0120.00718.62
8.2.100.0150.00718.01
8.2.90.0150.00518.13
8.2.80.0140.00618.31
8.2.70.0130.00630.28
8.2.60.0170.00517.99
8.2.50.0130.00518.04
8.2.40.0130.00418.14
8.2.30.0140.00417.95
8.2.20.0140.00517.96
8.2.10.0120.00618.18
8.2.00.0120.00718.14
8.1.310.0120.00616.27
8.1.300.0150.00716.47
8.1.290.0140.00519.16
8.1.280.0110.01018.12
8.1.270.0130.00719.43
8.1.260.0130.00419.99
8.1.250.0140.00620.14
8.1.240.0110.00718.66
8.1.230.0150.00418.46
8.1.220.0150.00517.92
8.1.210.0130.00517.87
8.1.200.0130.00417.86
8.1.190.0140.00617.83
8.1.180.0160.00317.88
8.1.170.0130.00617.83
8.1.160.0120.00617.91
8.1.150.0130.00417.93
8.1.140.0130.00617.85
8.1.130.0130.00518.18
8.1.120.0130.00517.97
8.1.110.0130.00417.76
8.1.100.0130.00617.79
8.1.90.0110.00617.81
8.1.80.0110.00617.78
8.1.70.0110.00517.67
8.1.60.0140.00517.81
8.1.50.0130.00617.80
8.1.40.0130.00517.81
8.1.30.0130.00517.76
8.1.20.0130.00617.86
8.1.10.0140.00617.77
8.1.00.0120.00617.68
8.0.300.0200.00417.38
8.0.290.0190.00516.97
8.0.280.0180.00517.47
8.0.270.0170.00417.53
8.0.260.0160.00617.33
8.0.250.0150.00417.34
8.0.240.0140.00717.35
8.0.230.0130.00517.27
8.0.220.0150.00417.25
8.0.210.0140.00517.23
8.0.200.0130.00417.21
8.0.190.0130.00617.29
8.0.180.0130.00517.25
8.0.170.0150.00417.24
8.0.160.0130.00617.32
8.0.150.0140.00617.19
8.0.140.0150.00517.16
8.0.130.0130.00717.00
8.0.120.0140.00617.17
8.0.110.0120.00617.24
8.0.100.0140.00517.13
8.0.90.0120.00517.13
8.0.80.0150.00517.20
8.0.70.0150.00417.23
8.0.60.0150.00517.17
8.0.50.0140.00417.19
8.0.30.0120.00617.25
8.0.20.0130.00517.30
8.0.10.0150.00317.27
8.0.00.0120.00517.45
7.4.330.0120.00516.48
7.4.320.0140.00616.91
7.4.300.0100.00516.69
7.4.290.0120.00716.81
7.4.280.0120.00616.78
7.4.270.0130.00516.76
7.4.260.0130.00516.59
7.4.250.0140.00516.77
7.4.240.0120.00516.75
7.4.230.0130.00516.73
7.4.220.0140.00316.75
7.4.210.0110.00616.76
7.4.200.0130.00416.77
7.4.190.0130.00416.79
7.4.180.0130.00516.78
7.4.160.0130.00416.79
7.4.150.0120.00416.73
7.4.140.0130.00416.66
7.4.130.0130.00416.63
7.4.120.0120.00516.64
7.4.110.0120.00516.58
7.4.100.0110.00516.71
7.4.90.0110.00616.64
7.4.80.0120.00516.64
7.4.70.0120.00516.58
7.4.60.0130.00416.63
7.4.50.0120.00416.57
7.4.40.0120.00416.59
7.4.30.0110.00516.60
7.4.20.0110.00416.62
7.4.10.0110.00516.62
7.4.00.0110.00516.64
7.3.330.0130.00516.59
7.3.320.0140.00516.43
7.3.310.0130.00416.61
7.3.300.0130.00416.63
7.3.290.0120.00516.57
7.3.280.0130.00416.60
7.3.270.0140.00416.58
7.3.260.0130.00516.57
7.3.250.0130.00516.55
7.3.240.0130.00516.56
7.3.230.0140.00416.58
7.3.220.0140.00416.51
7.3.210.0140.00516.55
7.3.200.0140.00516.51
7.3.190.0140.00416.54
7.3.180.0150.00416.53
7.3.170.0150.00416.55
7.3.160.0140.00416.51
7.3.150.0140.00516.55
7.3.140.0130.00516.55
7.3.130.0140.00516.50
7.3.120.0110.00616.54
7.3.110.0130.00516.53
7.3.100.0150.00416.51
7.3.90.0140.00416.72
7.3.80.0150.00416.50
7.3.70.0130.00516.59
7.3.60.0150.00316.62
7.3.50.0140.00416.58
7.3.40.0130.00516.63
7.3.30.0120.00616.64
7.3.20.0180.00517.34
7.3.10.0150.00417.24
7.3.00.0160.00517.27

preferences:
36.85 ms | 403 KiB | 5 Q