3v4l.org

run code in 300+ PHP versions simultaneously
<?php // http://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB function strtocolour($tstr) { $crc = unpack('L', hash('crc32', $tstr, true))[1]; $Hp = $crc / (0xFFFFFFFF / 6); $S = 0.8; // change as desired $V = 0.8; // change as desired $C = $V*$S; $X = $C*(1 - abs(fmod($Hp, 2) - 1)); $m = $V - $C; $i = 1+min(5, intval($Hp)); $comp = [ [$C, $X, 0], [$X, $C, 0], [ 0, $C, $X], [ 0, $X, $C], [$X, 0, $C], [$C, 0, $X]][$i]; $r = intval(255*($m + $comp[0])); $g = intval(255*($m + $comp[1])); $b = intval(255*($m + $comp[2])); return sprintf("#%02X%02X%02X", $r, $g, $b); } function test($tstr) { echo '<span style="color:"'.strtocolour($tstr).'">'; echo htmlspecialchars($tstr); echo '</span>'; } test('I'); test('am'); test('a'); test('fluffy'); test('bunny'); ?>
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
<span style="color:"#3428CC">I</span><span style="color:"#CC28BE">am</span><span style="color:"#8ACC28">a</span><span style="color:"#A6CC28">fluffy</span><span style="color:"#CC2899">bunny</span>
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '[' in /in/NYNX9 on line 19
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/NYNX9 on line 5
Process exited with code 255.

preferences:
223.15 ms | 401 KiB | 329 Q