What is data serialization ?

后端 未结 5 1690
后悔当初
后悔当初 2021-01-31 02:33

First of all, I could not able to get clear definition of it from WikiPedia or even from serialize function in the PHP manual. I need to know some cases we need the term seriali

5条回答
  •  野性不改
    2021-01-31 03:00

    Serialization is the process of converting some in-memory object to another format that could be used to either store in a file or sent over the network. Deserialization is the inverse process meaning the actual object instance is restored from the given serialized representation of the object. This is very useful when communicating between various systems.

    The serialization format could be either interoperable or non-interoperable. Interoperable formats (such as JSON, XML, ...) allow for serializing some object using a given platform and deserializing it using a different platform. For example with JSON you could use javascript to serialize the object and send it over the network to a PHP script that will deserialize the object and use it.

    The serialize() PHP function uses an non-interoperable format. This means that only PHP could be used to both serialize and deserialize the object back.

    You could use the json_encode and json_decode() functions in order to serialize/deserialize PHP objects using the JSON interoperable format.

提交回复
热议问题