3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class User { protected const STATUS_ACTIVE = 'active'; protected const STATUS_INACTIVE = 'inactive'; public function __construct(protected string $username, protected string $status = self::STATUS_ACTIVE) { } protected 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; } protected 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.10.0060.00317.55
8.3.140.0110.00716.94
8.3.130.0060.00316.72
8.3.120.0060.00419.01
8.3.110.0030.00718.89
8.3.100.0130.01028.91
8.3.90.0080.00621.73
8.3.80.0050.00517.48
8.3.70.0090.00516.69
8.3.60.0110.00516.68
8.3.50.0090.00316.49
8.3.40.0130.00018.28
8.3.30.0060.00718.00
8.3.20.0110.00622.54
8.3.10.0090.00421.94
8.3.00.0090.00421.41
8.2.260.0100.00716.66
8.2.250.0050.00318.65
8.2.240.0090.00617.24
8.2.230.0070.00819.44
8.2.220.0120.00527.07
8.2.210.0070.00721.49
8.2.200.0130.00416.58
8.2.190.0090.00817.43
8.2.180.0190.00021.23
8.2.170.0140.00818.22
8.2.160.0150.00720.27
8.2.150.0080.00821.41
8.2.140.0130.00421.43
8.2.130.0120.00521.88
8.2.120.0110.00621.62
8.2.110.0120.00619.42
8.2.100.0140.00418.64
8.2.90.0120.00319.16
8.2.80.0120.00218.85
8.2.70.0100.00542.92
8.2.60.0080.00918.47
8.2.50.0120.00618.95
8.2.40.0100.00518.47
8.2.30.0090.00619.08
8.2.20.0090.00518.81
8.2.10.0090.00719.18
8.2.00.0090.00618.92
8.1.310.0090.00617.00
8.1.300.0070.01118.58
8.1.290.0100.00623.51
8.1.280.0130.00721.05
8.1.270.0090.00721.70
8.1.260.0120.00422.44
8.1.250.0120.00322.99
8.1.240.0110.00518.95
8.1.230.0070.00918.36
8.1.220.0100.00518.36
8.1.210.0080.00818.72
8.1.200.0110.00518.38
8.1.190.0120.00418.17
8.1.180.0100.00418.68
8.1.170.0110.00418.72
8.1.160.0090.00418.96
8.1.150.0100.00519.04
8.1.140.0090.00618.98
8.1.130.0080.00518.96
8.1.120.0100.00618.32
8.1.110.0080.00618.05
8.1.100.0120.00418.02
8.1.90.0090.00517.84
8.1.80.0080.00617.89
8.1.70.0070.00617.75
8.1.60.0100.00617.80
8.1.50.0110.00617.81
8.1.40.0120.00417.83
8.1.30.0100.00517.89
8.1.20.0120.00417.90
8.1.10.0100.00517.77
8.1.00.0110.00617.73
8.0.300.0110.00418.35
8.0.290.0130.00717.00
8.0.280.0120.00718.15
8.0.270.0100.00518.13
8.0.260.0130.00817.99
8.0.250.0130.00417.54
8.0.240.0100.00617.55
8.0.230.0120.00417.28
8.0.220.0080.00717.20
8.0.210.0090.00617.26
8.0.200.0100.00417.19
8.0.190.0090.00617.12
8.0.180.0090.00617.10
8.0.170.0100.00417.14
8.0.160.0100.00417.16
8.0.150.0100.00517.01
8.0.140.0090.00616.98
8.0.130.0100.00516.93
8.0.120.0110.00516.74
8.0.110.0110.00316.81
8.0.100.0110.00416.79
8.0.90.0090.00516.77
8.0.80.0100.00416.78
8.0.70.0100.00516.80
8.0.60.0100.00416.75
8.0.50.0100.00516.74
8.0.30.0090.00516.79
8.0.20.0110.00416.88
8.0.10.0100.00616.92
8.0.00.0070.00617.32
7.4.330.0080.00316.13
7.4.320.0090.00616.81
7.4.300.0100.00416.60
7.4.290.0110.00316.61
7.4.280.0120.00416.58
7.4.270.0120.00416.51
7.4.260.0120.00516.42
7.4.250.0120.00516.28
7.4.240.0100.00516.26
7.4.230.0100.00416.33
7.4.220.0100.00416.28
7.4.210.0100.00416.36
7.4.200.0100.00416.29
7.4.190.0090.00516.36
7.4.180.0100.00416.39
7.4.160.0090.00416.32
7.4.150.0090.00416.23
7.4.140.0070.00516.25
7.4.130.0080.00516.15
7.4.120.0080.00516.13
7.4.110.0090.00416.13
7.4.100.0080.00516.25
7.4.90.0080.00516.15
7.4.80.0100.00416.12
7.4.70.0080.00516.18
7.4.60.0080.00516.16
7.4.50.0090.00416.07
7.4.40.0090.00416.14
7.4.30.0100.00316.16
7.4.20.0090.00416.16
7.4.10.0080.00516.21
7.4.00.0080.00416.21
7.3.330.0110.00516.28
7.3.320.0120.00416.14
7.3.310.0120.00416.07
7.3.300.0110.00416.19
7.3.290.0110.00416.05
7.3.280.0110.00416.07
7.3.270.0110.00416.10
7.3.260.0110.00416.07
7.3.250.0110.00516.08
7.3.240.0100.00516.05
7.3.230.0110.00516.06
7.3.220.0110.00516.01
7.3.210.0110.00416.04
7.3.200.0110.00416.03
7.3.190.0110.00416.04
7.3.180.0110.00416.04
7.3.170.0100.00516.06
7.3.160.0100.00516.05
7.3.150.0110.00416.04
7.3.140.0100.00516.11
7.3.130.0110.00416.02
7.3.120.0100.00516.04
7.3.110.0110.00416.05
7.3.100.0110.00416.02
7.3.90.0100.00516.26
7.3.80.0100.00516.06
7.3.70.0120.00416.08
7.3.60.0110.00516.17
7.3.50.0110.00416.11
7.3.40.0100.00516.15
7.3.30.0100.00516.14
7.3.20.0110.00517.50
7.3.10.0110.00417.45
7.3.00.0120.00417.50

preferences:
43.27 ms | 403 KiB | 5 Q