3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum ProductCategories: string { case A = 'A'; case B = 'B'; case C = 'C'; case D = 'D'; } interface ProductCategoryProviderInterface { public function getLocalCategoryId(ProductCategories $category): ?string; } class A implements ProductCategoryProviderInterface { public function getLocalCategoryId(ProductCategories $category): ?string { return match ($category) { ProductCategories::A => '1', ProductCategories::B => '2', default => null, }; } } class B implements ProductCategoryProviderInterface { public function getLocalCategoryId(ProductCategories $category): ?string { return match ($category) { ProductCategories::A => 'cat_a', ProductCategories::B => 'cat_B', default => null, }; } } echo (new A())->getLocalCategoryId(ProductCategories::A) . "\n"; // 1 echo (new B())->getLocalCategoryId(ProductCategories::A) . "\n"; // cat_a echo (new A())->getLocalCategoryId(ProductCategories::B) . "\n"; // 2 echo (new B())->getLocalCategoryId(ProductCategories::B) . "\n"; // cat_b echo (new A())->getLocalCategoryId(ProductCategories::C) . "\n"; // null

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.0080.00919.63
8.5.00.0060.01221.77
8.4.160.0120.01122.00
8.4.150.0010.00114.05
8.4.140.0160.00717.76
8.4.130.0100.01018.81
8.4.120.0110.01017.63
8.4.110.0120.01022.54
8.4.100.0140.00717.71
8.4.90.0110.00920.88
8.4.80.0050.00318.83
8.4.70.0060.00218.68
8.4.60.0170.00520.37
8.4.50.0150.00517.69
8.4.40.0150.00417.76
8.4.30.0210.00024.28
8.4.20.0060.01319.71
8.4.10.0160.00319.48
8.3.280.0140.00618.22
8.3.270.0120.00816.41
8.3.260.0110.00716.63
8.3.250.0120.00716.62
8.3.240.0160.00316.64
8.3.230.0040.00516.85
8.3.220.0110.00618.76
8.3.210.0060.00216.47
8.3.200.0060.00416.76
8.3.190.0110.00716.76
8.3.180.0110.00518.55
8.3.170.0140.00317.20
8.3.160.0170.00020.41
8.3.150.0070.01317.29
8.3.140.0040.00416.51
8.3.130.0070.00716.59
8.3.120.0100.01016.36
8.3.110.0190.01516.67
8.3.100.0200.00416.65
8.3.90.0230.00316.50
8.3.80.0180.00516.41
8.3.70.0350.00316.25
8.3.60.0380.00316.33
8.3.50.0360.01116.56
8.3.40.0350.00817.63
8.3.30.0320.00817.26
8.3.20.0270.00417.39
8.3.10.0250.00917.46
8.3.00.0150.00817.42
8.2.290.0070.00616.49
8.2.280.0110.00918.35
8.2.270.0100.01016.68
8.2.260.0090.00917.11
8.2.250.0080.00316.48
8.2.240.0330.00716.44
8.2.230.0300.01016.24
8.2.220.0400.00016.04
8.2.210.0310.00615.96
8.2.200.0200.00516.48
8.2.190.0390.00616.20
8.2.180.0270.00716.35
8.2.170.0200.00017.71
8.2.160.0150.00417.45
8.2.150.0150.00417.34
8.2.140.0120.00917.46
8.2.130.0210.00417.45
8.2.120.0350.00817.36
8.2.110.0310.00817.41
8.2.100.0220.01117.52
8.2.90.0380.00317.28
8.2.80.0300.01117.39
8.2.70.0350.00717.53
8.2.60.0390.00317.45
8.2.50.0380.00317.32
8.2.40.0310.00817.36
8.2.30.0350.00417.29
8.2.20.0320.00717.20
8.2.10.0360.00317.29
8.2.00.0330.00717.28
8.1.330.0110.00716.35
8.1.320.0100.01017.75
8.1.310.0120.00618.54
8.1.300.0330.00915.78
8.1.290.0390.00616.03
8.1.280.0260.01015.86
8.1.270.0280.00317.04
8.1.260.0220.00617.20
8.1.250.0330.01017.28
8.1.240.0340.00317.23
8.1.230.0340.00316.84
8.1.220.0300.00917.20
8.1.210.0370.00317.16
8.1.200.0340.00617.20
8.1.190.0300.00817.03
8.1.180.0260.01117.08
8.1.170.0320.00717.06
8.1.160.0290.00017.13
8.1.150.0260.01117.21
8.1.140.0220.01516.95
8.1.130.0250.01217.05
8.1.120.0260.01217.14
8.1.110.0330.00516.98
8.1.100.0270.01017.18
8.1.90.0330.00417.27
8.1.80.0270.01016.99
8.1.70.0300.00617.06
8.1.60.0190.00817.23
8.1.50.0200.00017.27
8.1.40.0190.00417.18
8.1.30.0270.01217.50
8.1.20.0290.00317.44
8.1.10.0120.01217.12
8.1.00.0400.00717.13

preferences:
34.31 ms | 403 KiB | 5 Q