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

Breadcrumb

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

function HeaderUtils::quote

Encodes a string as a quoted string, if necessary.

If a string contains characters not allowed by the "token" construct in the HTTP specification, it is backslash-escaped and enclosed in quotes to match the "quoted-string" construct.

1 call to HeaderUtils::quote()
HeaderUtils::toString in vendor/symfony/http-foundation/HeaderUtils.php
Joins an associative array into a string for use in an HTTP header.

File

vendor/symfony/http-foundation/HeaderUtils.php, line 132

Class

HeaderUtils
HTTP header utility functions.

Namespace

Symfony\Component\HttpFoundation

Code

public static function quote(string $s) : string {
    if (preg_match('/^[a-z0-9!#$%&\'*.^_`|~-]+$/i', $s)) {
        return $s;
    }
    return '"' . addcslashes($s, '"\\"') . '"';
}

API Navigation

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