public static function String::checkPlain

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

Also validates strings as UTF-8.

Parameters

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

Return value

string An HTML safe version of $text, or an empty string if $text is not valid UTF-8.

See also

drupal_validate_utf8()

Related topics

12 calls to String::checkPlain()
ActionListController::buildRow in drupal/core/modules/action/lib/Drupal/action/ActionListController.php
Builds a row for an entity in the entity listing.
AttributeString::__toString in drupal/core/lib/Drupal/Core/Template/AttributeString.php
Implements the magic __toString() method.
check_plain in drupal/core/includes/bootstrap.inc
Encodes special characters in a plain-text string for display as HTML.
check_url in drupal/core/includes/common.inc
Strips dangerous protocols from a URI and encodes it for output to HTML.
DateFormatFormBase::submitForm in drupal/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php
Form submission handler.

... See full list

File

drupal/core/lib/Drupal/Component/Utility/String.php, line 31
Contains \Drupal\Component\Utility\String.

Class

String
Provides helpers to operate on strings.

Namespace

Drupal\Component\Utility

Code

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