function SerializationInterface::encode

Same name in other branches
  1. 9 core/lib/Drupal/Component/Serialization/SerializationInterface.php \Drupal\Component\Serialization\SerializationInterface::encode()
  2. 8.9.x core/lib/Drupal/Component/Serialization/SerializationInterface.php \Drupal\Component\Serialization\SerializationInterface::encode()
  3. 11.x core/lib/Drupal/Component/Serialization/SerializationInterface.php \Drupal\Component\Serialization\SerializationInterface::encode()

Encodes data into the serialization format.

Parameters

mixed $data: The data to encode.

Return value

string The encoded data.

Throws

\Drupal\Component\Serialization\Exception\InvalidDataTypeException

4 methods override SerializationInterface::encode()
Json::encode in core/lib/Drupal/Component/Serialization/Json.php
Uses HTML-safe strings, with several characters escaped.
Yaml::encode in core/lib/Drupal/Component/Serialization/Yaml.php
Encodes data into the serialization format.
YamlPecl::encode in core/lib/Drupal/Component/Serialization/YamlPecl.php
Encodes data into the serialization format.
YamlSymfony::encode in core/lib/Drupal/Component/Serialization/YamlSymfony.php
Encodes data into the serialization format.

File

core/lib/Drupal/Component/Serialization/SerializationInterface.php, line 21

Class

SerializationInterface
Defines an interface for serialization formats.

Namespace

Drupal\Component\Serialization

Code

public static function encode($data);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.