在PHP中,你可以使用正则表达式来检查一个字符串是否为合法的十六进制颜色值。以下是一个示例函数: function is_color($colorCode) { if (preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/..