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