sanitize_key()

清理字符串键。

sanitize_key(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.0wp-includes/formatting.php:2132552
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索