常用函数-sanitize_user()

0条评论

常用函数-sanitize_user()

说明

消除用户名中的不安全字符。

若$strict参数为true,则返回添加了_, space, ., -, *, 以及 @的字母数字式字符。

该函数删除所有标签,XX以及实体,如果$strict参数被激活,该函数删除所有非ASCII字符。清理用户名后,该函数将用户名、原始用户名(参数中的用户名)以及$strict参数作为过滤器参数。

用法

<?php sanitize_user( $username, $strict ) ?>

参数

$username

(字符串)(必需)被检查的用户名

默认值:None

$strict

(布尔值)(可选)是否规定可以用在$username中的字符串

默认值:false

返回的值

(字符串)

经过检查并传递参数给过滤器后的用户名

示例

注释

  • 用法:apply_filters()在用户名、原始用户名以及$strict参数上调用'sanitize_user' hook

修改记录

自2.0.0版本后

源文件

sanitize_user()位于 wp-includes/formatting.php中。

相关资源

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.