清理字符串键。
原型
sanitize_key( string $key )
描述
密钥用作内部标识符。允许使用小写字母数字字符,破折号和下划线。
参数
$key
(string)
(Required)
字符串键
返回值
(string)
消毒钥匙
源文件
路径:wp-includes/formatting.php
<?php
...
function sanitize_key( $key ) {
$raw_key = $key;
$key = strtolower( $key );
$key = preg_replace( '/[^a-z0-9_-]/', '', $key );
/**
* Filters a sanitized key string.
*
* @since 3.0.0
*
* @param string $key Sanitized key.
* @param string $raw_key The key prior to sanitization.
*/
return apply_filters( 'sanitize_key', $key, $raw_key );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/sanitize_key/