1.20.x bootstrap.inc check_plain($text)

Encodes special characters in a plain-text string for display as HTML.

Also validates strings as UTF-8 to prevent cross site scripting attacks on Internet Explorer 6.

Parameters

string $text: The text to be checked or processed.

Return value

string: An HTML safe version of $text. If $text is not valid UTF-8, an empty string is returned and, on PHP < 5.4, a warning may be issued depending on server configuration (see https://bugs.php.net/bug.php?id=47494).

See also

backdrop_validate_utf8()

Related topics

File

includes/bootstrap.inc, line 2311
Functions that need to be loaded on every Backdrop request.

Code

function check_plain($text) {
  return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}