You are here

public static function WebformHtmlHelper::containsHtml in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Utility/WebformHtmlHelper.php \Drupal\webform\Utility\WebformHtmlHelper::containsHtml()

Determine if a string value contains HTML markup or entities.

Parameters

string $string: A string.

Return value

bool TRUE if the string value contains HTML markup or entities.

5 calls to WebformHtmlHelper::containsHtml()
WebformComputedBase::getMode in src/Element/WebformComputedBase.php
Get an element's value mode/type.
WebformHtmlHelper::toHtmlMarkup in src/Utility/WebformHtmlHelper.php
Convert string to safe HTML markup.
WebformHtmlHelper::toPlainText in src/Utility/WebformHtmlHelper.php
Convert HTML markup to plain text.
WebformHtmlHelperTest::testContainsHtml in tests/src/Unit/Utility/WebformHtmlHelperTest.php
Tests WebformHtmlHelper::containsHtml().
WebformTwigExtension::webformToken in src/Twig/WebformTwigExtension.php
Replace tokens in text.

File

src/Utility/WebformHtmlHelper.php, line 65

Class

WebformHtmlHelper
Provides HTML helper functions.

Namespace

Drupal\webform\Utility

Code

public static function containsHtml($string) {
  return preg_match('/(<[a-z][^>]*>|&(?:[a-z]+|#\\d+);)/i', $string) ? TRUE : FALSE;
}