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

Breadcrumb

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

function String_::parse

@internal

Parses a string token.

Parameters

string $str String token content:

bool $parseUnicodeEscape Whether to parse PHP 7 \u escapes:

Return value

string The parsed string

1 call to String_::parse()
String_::fromString in vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php

File

vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php, line 71

Class

String_

Namespace

PhpParser\Node\Scalar

Code

public static function parse(string $str, bool $parseUnicodeEscape = true) : string {
    $bLength = 0;
    if ('b' === $str[0] || 'B' === $str[0]) {
        $bLength = 1;
    }
    if ('\'' === $str[$bLength]) {
        return str_replace([
            '\\\\',
            '\\\'',
        ], [
            '\\',
            '\'',
        ], substr($str, $bLength + 1, -1));
    }
    else {
        return self::parseEscapeSequences(substr($str, $bLength + 1, -1), '"', $parseUnicodeEscape);
    }
}

API Navigation

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