sanitize_key()
sanitize_key( string $key ) 清理字符串键。Sanitizes a string k…
sanitize_key( string $key )
清理字符串键。
Sanitizes a string key.
清理字符串键。
Sanitizes a string key.
目录锚点:#说明#参数#返回#源码
说明(Description)
密钥用作内部标识符。允许使用小写字母数字字符、破折号和下划线。
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $key | (string) | 必需 | 字符串键 |
返回(Return)
(string)经过消毒的密钥
源码(Source)
/**
* Sanitizes a string key.
*
* Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed.
*
* @since 3.0.0
*
* @param string $key String key
* @return string Sanitized key
*/
function sanitize_key( $key ) {
$raw_key = $key;
$key = strtolower( $key );
$key = preg_replace( '/[^a-z0-9_-]/', '', $key );
/**
* Filter 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 );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 3.0.0 | wp-includes/formatting.php:2132 | 55 | 2 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!