Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

sanitize_hex_color_no_hash()

3 tags 1 category

sanitize_hex_color_no_hash() — Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible. Saving hex colors without a hash puts the burden of adding the hash on the UI, which makes it difficult to use or upgrade to other color types such as rgba, hsl, rgb, and HTML color names. Returns either ”, a 3 or 6 digit hex color (without a #), or null.

Inputs: $color (string): The color value to sanitize. Can be with or without a #.

Returns string|null: The sanitized hex color without the hash prefix, empty string if input is empty, or null if invalid.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…