Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Utils.php

function Utils::quoteLiteralString

This function converts a string to a quoted javascript string

Parameters

string $str String to quote:

string $quote Quote character:

Return value

string

2 calls to Utils::quoteLiteralString()
StringLiteral::setFormat in vendor/mck89/peast/lib/Peast/Syntax/Node/StringLiteral.php
Sets string format
TemplateElement::setValue in vendor/mck89/peast/lib/Peast/Syntax/Node/TemplateElement.php
Sets node's value

File

vendor/mck89/peast/lib/Peast/Syntax/Utils.php, line 214

Class

Utils
Utilities class.

Namespace

Peast\Syntax

Code

public static function quoteLiteralString($str, $quote) {
    $escape = self::getLineTerminators();
    $escape[] = $quote;
    $escape[] = "\\\\";
    $reg = "/(" . implode("|", $escape) . ")/";
    $str = preg_replace($reg, "\\\\\$1", $str);
    return $quote . $str . $quote;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal