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.3.60.0110.01116.75
8.3.50.0090.00616.55
8.3.40.0060.01218.67
8.3.30.0000.01518.83
8.3.20.0100.00323.80
8.3.10.0070.00724.07
8.3.00.0090.00523.48
8.2.180.0180.00425.92
8.2.170.0070.01418.88
8.2.160.0130.00022.96
8.2.150.0040.00723.26
8.2.140.0030.00823.45
8.2.130.0050.00524.12
8.2.120.0040.00721.11
8.2.110.0060.00720.94
8.2.100.0150.00418.72
8.2.90.0120.00818.78
8.2.80.0110.00519.08
8.2.70.0120.00538.86
8.2.60.0150.00518.58
8.2.50.0110.00418.42
8.2.40.0100.00418.41
8.2.30.0120.00418.19
8.2.20.0110.00518.19
8.2.10.0110.00518.53
8.2.00.0100.00618.42
8.1.280.0040.01125.92
8.1.270.0050.00623.90
8.1.260.0060.00525.06
8.1.250.0050.00526.03
8.1.240.0040.00721.54
8.1.230.0120.00320.14
8.1.220.0160.00418.82
8.1.210.0140.00618.84
8.1.200.0140.00318.59
8.1.190.0110.00618.48
8.1.180.0160.00118.50
8.1.170.0120.00618.18
8.1.160.0100.00718.29
8.1.150.0130.00518.30
8.1.140.0120.00518.20
8.1.130.0120.00518.67
8.1.120.0120.00518.29
8.1.110.0110.00518.01
8.1.100.0110.00618.01
8.1.90.0100.00618.04
8.1.80.0090.00717.95
8.1.70.0100.00517.77
8.1.60.0130.00417.93
8.1.50.0120.00517.94
8.1.40.0120.00617.91
8.1.30.0130.00517.85
8.1.20.0120.00517.98
8.1.10.0130.00517.88
8.1.00.0120.00517.76
8.0.300.0160.00318.43
8.0.290.0170.00317.50
8.0.280.0160.00417.91
8.0.270.0130.00418.00
8.0.260.0140.00617.76
8.0.250.0160.00217.61
8.0.240.0130.00517.60
8.0.230.0120.00517.51
8.0.220.0120.00417.47
8.0.210.0120.00517.45
8.0.200.0130.00417.44
8.0.190.0120.00517.46
8.0.180.0110.00517.43
8.0.170.0140.00317.40
8.0.160.0110.00617.47
8.0.150.0120.00617.33
8.0.140.0130.00517.34
8.0.130.0110.00617.10
8.0.120.0120.00617.34
8.0.110.0100.00717.42
8.0.100.0110.00517.29
8.0.90.0100.00517.26
8.0.80.0130.00417.34
8.0.70.0120.00417.41
8.0.60.0130.00417.32
8.0.50.0120.00517.36
8.0.30.0110.00517.38
8.0.20.0120.00417.44
8.0.10.0130.00317.38
8.0.00.0100.00517.62
7.4.330.0080.00416.66
7.4.320.0110.00617.23
7.4.300.0090.00416.82
7.4.290.0100.00717.03
7.4.280.0100.00616.95
7.4.270.0120.00516.94
7.4.260.0110.00516.74
7.4.250.0120.00516.93
7.4.240.0110.00416.93
7.4.230.0110.00616.89
7.4.220.0130.00316.92
7.4.210.0090.00616.92
7.4.200.0110.00516.93
7.4.190.0110.00416.94
7.4.180.0110.00516.94
7.4.160.0110.00416.92
7.4.150.0110.00416.89
7.4.140.0110.00316.82
7.4.130.0110.00416.79
7.4.120.0100.00416.78
7.4.110.0100.00416.76
7.4.100.0100.00516.87
7.4.90.0090.00616.80
7.4.80.0100.00516.80
7.4.70.0090.00516.74
7.4.60.0110.00416.79
7.4.50.0100.00416.73
7.4.40.0110.00416.75
7.4.30.0100.00416.74
7.4.20.0100.00416.75
7.4.10.0090.00516.79
7.4.00.0100.00416.80
7.3.330.0130.00416.77
7.3.320.0120.00516.58
7.3.310.0120.00416.77
7.3.300.0120.00516.80
7.3.290.0120.00516.76
7.3.280.0120.00416.76
7.3.270.0130.00316.74
7.3.260.0120.00516.73
7.3.250.0120.00516.71
7.3.240.0120.00516.71
7.3.230.0130.00416.75
7.3.220.0130.00416.67
7.3.210.0130.00416.69
7.3.200.0130.00516.65
7.3.190.0120.00416.70
7.3.180.0130.00316.67
7.3.170.0130.00416.71
7.3.160.0130.00416.67
7.3.150.0120.00416.69
7.3.140.0110.00516.69
7.3.130.0120.00516.68
7.3.120.0090.00716.69
7.3.110.0120.00516.71
7.3.100.0130.00416.67
7.3.90.0120.00516.85
7.3.80.0140.00316.67
7.3.70.0120.00516.75
7.3.60.0130.00316.78
7.3.50.0130.00416.75
7.3.40.0120.00516.78
7.3.30.0110.00616.78
7.3.20.0140.00417.55
7.3.10.0140.00417.46
7.3.00.0140.00517.47

preferences:
44.1 ms | 400 KiB | 5 Q