3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ColorLuminance($hex, $lum) { // validate hex string $hex = preg_replace("/[^0-9a-f]/i", "", $hex); if (strlen($hex) < 6) { $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; } // convert to decimal and change luminosity $rgb = "#"; for ($i = 0; $i < 3; $i++) { //echo substr($hex, $i * 2, 2) . " * "; $c = base_convert(substr($hex, $i * 2, 2), 16, 10); //echo $c . " - "; $c = base_convert((round(min(max(0, floatval($c + ($c * $lum))),255))), 10, 16); //echo $c . " - "; $rgb .= substr('00' . $c, strlen($c)); //echo $rgb . " - "; } return $rgb; } echo ColorLuminance("#69c", 0) . "\n"; // returns "#6699cc" echo ColorLuminance("6699CC", 0.2) . "\n";// "#7ab8f5" - 20% lighter echo ColorLuminance("69C", -0.5) . "\n";// "#334d66" - 50% darker echo ColorLuminance("000", 1) . "\n";// "#000000" - true black cannot be made lighter!

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.0070.00716.75
8.3.50.0080.00922.03
8.3.40.0140.00719.18
8.3.30.0090.00619.06
8.3.20.0060.00320.30
8.3.10.0000.00823.64
8.3.00.0030.00519.91
8.2.180.0140.00718.48
8.2.170.0130.00322.96
8.2.160.0110.00720.52
8.2.150.0080.00024.18
8.2.140.0140.00024.66
8.2.130.0050.00326.16
8.2.120.0080.00020.96
8.2.110.0100.00020.60
8.2.100.0030.01017.97
8.2.90.0000.00818.24
8.2.80.0000.00817.97
8.2.70.0030.00517.88
8.2.60.0070.00318.16
8.2.50.0000.01018.07
8.2.40.0060.00318.27
8.2.30.0000.00818.30
8.2.20.0040.00418.07
8.2.10.0040.00418.14
8.2.00.0040.00417.90
8.1.280.0070.00725.92
8.1.270.0040.00423.96
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0050.00521.99
8.1.230.0030.00920.85
8.1.220.0000.00817.78
8.1.210.0000.00818.95
8.1.200.0030.00617.50
8.1.190.0080.00017.38
8.1.180.0050.00318.10
8.1.170.0080.00018.72
8.1.160.0000.00722.20
8.1.150.0040.00418.98
8.1.140.0000.00817.66
8.1.130.0070.00017.81
8.1.120.0040.00417.73
8.1.110.0040.00417.66
8.1.100.0030.00517.68
8.1.90.0000.00717.61
8.1.80.0030.00517.66
8.1.70.0070.00017.62
8.1.60.0000.00817.71
8.1.50.0080.00017.72
8.1.40.0000.00817.65
8.1.30.0040.00417.86
8.1.20.0050.00317.87
8.1.10.0000.00717.80
8.1.00.0030.00617.62
8.0.300.0040.00420.12
8.0.290.0000.00817.00
8.0.280.0030.00318.46
8.0.270.0030.00317.36
8.0.260.0000.00617.22
8.0.250.0040.00417.30
8.0.240.0040.00417.25
8.0.230.0000.00817.23
8.0.220.0040.00417.11
8.0.210.0000.00717.18
8.0.200.0000.00617.16
8.0.190.0000.00817.21
8.0.180.0100.00017.18
8.0.170.0080.00017.26
8.0.160.0040.00417.04
8.0.150.0000.00717.16
8.0.140.0050.00517.02
8.0.130.0000.00513.66
8.0.120.0080.00017.13
8.0.110.0040.00417.06
8.0.100.0000.00717.29
8.0.90.0000.00717.21
8.0.80.0120.00417.16
8.0.70.0040.00416.97
8.0.60.0000.00717.00
8.0.50.0030.00517.14
8.0.30.0060.01517.32
8.0.20.0170.00517.40
8.0.10.0070.00017.15
8.0.00.0100.00816.96
7.4.330.0050.00015.16
7.4.320.0000.00616.91
7.4.300.0000.00616.73
7.4.290.0000.00716.83
7.4.280.0080.00316.67
7.4.270.0030.00316.80
7.4.260.0070.00316.86
7.4.250.0030.00616.85
7.4.240.0000.00716.77
7.4.230.0070.00016.87
7.4.220.0070.01116.91
7.4.210.0100.00516.82
7.4.200.0050.00216.77
7.4.160.0060.00916.96
7.4.150.0100.01017.40
7.4.140.0120.00517.86
7.4.130.0080.00916.71
7.4.120.0090.00816.88
7.4.110.0030.01716.72
7.4.100.0150.00416.89
7.4.90.0110.00616.74
7.4.80.0070.01019.39
7.4.70.0130.00616.79
7.4.60.0100.00816.89
7.4.50.0040.00416.67
7.4.40.0060.01016.64
7.4.30.0120.00316.92
7.4.00.0130.00315.43
7.3.330.0000.00713.58
7.3.320.0030.00313.56
7.3.310.0040.00416.61
7.3.300.0000.00716.56
7.3.290.0030.01216.57
7.3.280.0100.01016.57
7.3.270.0100.00717.40
7.3.260.0090.01116.77
7.3.250.0120.00616.81
7.3.240.0180.00716.83
7.3.230.0060.01116.55
7.3.210.0150.00316.51
7.3.200.0060.01019.39
7.3.190.0140.00716.50
7.3.180.0090.00616.58
7.3.170.0090.01216.69
7.3.160.0120.00416.59
7.3.120.0120.00414.97
7.2.330.0020.01616.90
7.2.320.0110.00717.13
7.2.310.0060.01016.94
7.2.300.0090.00616.99
7.2.290.0100.00617.05
7.1.100.0000.01518.41
7.1.70.0040.00717.56
7.1.60.0060.01919.70
7.1.50.0100.01317.33
7.1.00.0130.06722.52
7.0.200.0000.01116.87
7.0.140.0000.07722.08
7.0.60.0070.08019.91
7.0.50.0070.03717.89
7.0.40.0070.08320.13
7.0.30.0200.06020.43
7.0.20.0200.04320.12
7.0.10.0030.05320.08
7.0.00.0030.05320.10
5.6.280.0030.07321.00
5.6.210.0100.06320.78
5.6.200.0070.08318.18
5.6.190.0070.04720.63
5.6.180.0230.03720.40
5.6.170.0330.07320.50
5.6.160.0170.07320.44
5.6.150.0100.04318.20
5.6.140.0030.05018.20
5.6.130.0070.07318.17
5.6.120.0070.08021.00
5.6.110.0100.07020.95
5.6.100.0100.06720.98
5.6.90.0130.07721.11
5.6.80.0070.08020.42
5.6.70.4530.04020.38
5.5.350.0100.07320.34
5.5.340.0030.04717.94
5.5.330.0000.07320.27
5.5.320.4030.04320.39
5.5.310.0230.04020.27
5.5.300.0030.04717.98
5.5.290.0030.08317.99
5.5.280.0100.03720.89
5.5.270.0130.03320.88
5.5.260.0170.07020.86
5.5.250.0130.08320.71
5.5.240.0130.04320.27
5.4.450.0370.05019.42
5.4.440.0370.03719.56
5.4.430.0530.03719.50
5.4.420.0300.04319.58
5.4.410.0400.04319.44
5.4.400.0200.04018.88
5.4.390.0500.04319.38
5.4.380.0130.05318.73
5.4.370.0130.05318.73
5.4.360.0200.05018.75
5.4.350.0170.05018.62
5.4.340.0200.05718.69
5.4.320.0050.04112.52
5.4.310.0090.03812.51
5.4.300.0090.04812.52
5.4.290.0050.06412.51
5.4.280.0100.04512.41
5.4.270.0130.07012.41
5.4.260.0100.04512.41
5.4.250.0050.04912.41
5.4.240.0080.04112.41
5.4.230.0050.04212.41
5.4.220.0100.04412.40
5.4.210.0080.04912.40
5.4.200.0110.04012.40
5.4.190.0070.03912.40
5.4.180.0080.04212.40
5.4.170.0060.04312.40
5.4.160.0050.04012.40
5.4.150.0100.03812.40
5.4.140.0070.04812.09
5.4.130.0150.03512.07
5.4.120.0050.03912.03
5.4.110.0120.03412.02
5.4.100.0070.03812.02
5.4.90.0080.04412.03
5.4.80.0150.04212.02
5.4.70.0050.04912.02
5.4.60.0080.04712.02
5.4.50.0100.04312.02
5.4.40.0080.03712.01
5.4.30.0070.03812.00
5.4.20.0050.03712.00
5.4.10.0090.03312.00
5.4.00.0050.03811.50
5.3.290.0040.04312.80
5.3.280.0070.03812.71
5.3.270.0060.04012.73
5.3.260.0050.04112.72
5.3.250.0120.03212.72
5.3.240.0060.03812.72
5.3.230.0080.03612.71
5.3.220.0050.03912.68
5.3.210.0070.04112.68
5.3.200.0130.04612.68
5.3.190.0090.05012.68
5.3.180.0100.04112.67
5.3.170.0070.04112.67
5.3.160.0050.04112.67
5.3.150.0120.08812.67
5.3.140.0080.04612.66
5.3.130.0070.04712.66
5.3.120.0070.04912.66
5.3.110.0100.03812.66
5.3.100.0080.03612.13
5.3.90.0070.03812.12
5.3.80.0090.03812.11
5.3.70.0070.04412.11
5.3.60.0100.04512.09
5.3.50.0090.04712.04
5.3.40.0060.04012.04
5.3.30.0110.06412.00
5.3.20.0180.05711.78
5.3.10.0110.05711.74
5.3.00.0060.04911.73
5.2.170.0040.0369.25
5.2.160.0080.0309.25
5.2.150.0040.0329.26
5.2.140.0070.0319.25
5.2.130.0080.0319.21
5.2.120.0070.0309.21
5.2.110.0070.0309.22
5.2.100.0080.0299.21
5.2.90.0060.0309.21
5.2.80.0040.0329.20
5.2.70.0050.0319.21
5.2.60.0050.0389.16
5.2.50.0100.0609.13
5.2.40.0040.0309.11
5.2.30.0060.0299.09
5.2.20.0050.0299.07
5.2.10.0060.0298.99
5.2.00.0050.0308.86
5.1.60.0060.0238.14
5.1.50.0080.0248.14
5.1.40.0070.0238.11
5.1.30.0030.0288.47
5.1.20.0090.0238.49
5.1.10.0060.0258.21
5.1.00.0070.0238.18
5.0.50.0030.0216.69
5.0.40.0050.0186.56
5.0.30.0060.0306.37
5.0.20.0050.0196.36
5.0.10.0030.0206.33
5.0.00.0050.0306.32
4.4.90.0030.0154.78
4.4.80.0040.0204.76
4.4.70.0090.0164.75
4.4.60.0030.0224.75
4.4.50.0040.0144.77
4.4.40.0030.0254.71
4.4.30.0020.0164.76
4.4.20.0020.0174.84
4.4.10.0040.0214.85
4.4.00.0030.0284.75
4.3.110.0060.0204.67
4.3.100.0060.0194.67
4.3.90.0050.0214.64
4.3.80.0040.0324.62
4.3.70.0040.0204.63
4.3.60.0030.0214.63
4.3.50.0030.0224.62
4.3.40.0030.0334.57
4.3.30.0020.0223.38
4.3.20.0010.0233.36
4.3.10.0070.0243.32
4.3.00.0030.01714.60

preferences:
39.7 ms | 401 KiB | 5 Q