WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/sanitize text field

Description

Sanitize a string from user input or from the db.

Checks for invalid UTF-8, Convert single < characters to entity, strip all tags, remove line breaks, tabs and extra white space, strip octets.

Usage

<?php sanitize_text_field$str ?>

Parameters

$str
(string) (required) String to be sanitized.
Default: None

Return Values

(string) 
Sanitized string.

Change Log

Source File

sanitize_text_field() is located in wp-includes/formatting.php

Related

Functions

sanitize_text_field() is in a class of functions that help you sanitize potentially unsafe data which allow you to pass an arbitrary variable and receive the clean version based on data type. Others include:

Filters

See also index of Function Reference and index of Template Tags.