Checks if a string is a proper hexadecimal HTML color value. The validation is quite flexible as it does not require an initial "#" and also allows for the short notation using only three instead of six hexadecimal characters.
boolean Core_Valid::color( string $str )
参数列表
参数 类型 描述 默认值 $str
string
Input string
boolean
public static function color($str)
{
return (bool)preg_match('/^#?+[0-9a-f]{3}(?:[0-9a-f]{3})?$/iD', $str);
}