3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getContrastYIQ($hexcolor){ $r = hexdec(substr($hexcolor,0,2)); $g = hexdec(substr($hexcolor,2,2)); $b = hexdec(substr($hexcolor,4,2)); $yiq = (($r*299)+($g*587)+($b*114))/1000; return ($yiq >= 128) ? 'black' : 'white'; } echo getContrastYIQ(000000);
Output for 4.3.0 - 7.1.0
white