WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/sanitize key

Description

Sanitize a string key. Keys are used as internal identifiers.

Lowercase alphanumeric characters, dashes and underscores are allowed. Uppercase characters will be converted to lowercase. After sanitize_key() has done its work, it passes the sanitized key through the sanitize_key filter.

Usage

<?php sanitize_key$key ); ?>

Parameters

$key
(string) (required) String key
Default: None

Return Values

(string) 
Sanitized key

Examples

Notes

Filters

  • 'sanitize_key':
    apply_filters( 'sanitize_key', $key, $raw_key )

Change Log

Since: 3.0.0

Source File

sanitize_key() is located in /wp-includes/formatting.php.

Related

Functions

sanitize_key() is in a class of functions that help you sanitize potentially unsafe data which allow you to pass an arbitrary variable and receive the clean version based on data type. Others include:

Filters