从用户输入或数据库中清除字符串。
原型
sanitize_text_field( string $str )
参数
$str
(string)
(Required)
要消毒的字符串。
返回值
(string)
消毒字符串。
源文件
路径:wp-includes/formatting.php
<?php
...
function sanitize_text_field( $str ) {
$filtered = _sanitize_text_fields( $str, false );
/**
* Filters a sanitized text field string.
*
* @since 2.9.0
*
* @param string $filtered The sanitized string.
* @param string $str The string prior to being sanitized.
*/
return apply_filters( 'sanitize_text_field', $filtered, $str );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/sanitize_text_field/