Tags::encode

public static Tags::encode($tag)

Encodes a tag string, taking care of special cases like commas and quotes.

Parameters

string $tag: A tag string.

Return value

string The encoded string.

File

core/lib/Drupal/Component/Utility/Tags.php, line 51

Class

Tags
Defines a class that can explode and implode tags.

Namespace

Drupal\Component\Utility

Code

public static function encode($tag) {
  if (strpos($tag, ',') !== FALSE || strpos($tag, '"') !== FALSE) {
    return '"' . str_replace('"', '""', $tag) . '"';
  }
  return $tag;
}
doc_Drupal
2016-10-29 09:46:15
Comments
Leave a Comment

Please login to continue.