Serialize data into a compact format that can be unserialized by fb_unserialize()

function fb_serialize(
  mixed $thing,
  int $options = 0,
): mixed;

WARNING: FB_SERIALIZE_HACK_ARRAYS_AND_KEYSETS mode has been added in March 2020, and support for underlying serialization format may not yet be available in all non-Hack implementations yet. Caution is adviced when using FB_SERIALIZE_HACK_ARRAYS_AND_KEYSETS for serializing data, which may be deserialized outside of Hack.


  • mixed $thing - What to serialize. Note that objects are not supported.
  • int $options = 0


  • mixed - - Serialized data.