sanitize_text_field() Overview
Cleans a string that comes from a form submission or is read from the database.
It checks whether the string is valid UTF-8, converts < into an HTML entity, strips all HTML tags, removes line breaks, placeholders, and extra spaces, and strips octets.
How to use sanitize_text_field()
Pass the string that needs to be sanitized into the function. The returned string is the cleaned version and can then be stored in the database with confidence.
<?php sanitize_text_field( $str ) ?>
sanitize_text_field() Parameters
sanitize_text_field() accepts only one argument: the string to sanitize. The default value is empty.
$string
(string) (required) The string to be cleaned.
Default: None
sanitize_text_field() Return value
The return value of sanitize_text_field() is the sanitized string.
(string)
The cleaned string
