What is data serialization ?

后端 未结 5 1638
后悔当初
后悔当初 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 02:56

    I need to know some cases we need the term serialization and how things are going without it?

    Serialization can become handy if you need to store complete structures (like an invoice with all associated data like customer address, sender address, product positions, tax caclulcations etc) that are only valid at a certain point in time.

    All these data will change in the future, new tax regulations might come, the address of a customer changes, products go out of life. But still the invoice needs to be valid and stored.

    This is possible with serialization. Like a snapshot. The object in memory are serialized into a (often like in PHP) binary form that can be just stored. It can be brought back to live later on (and in a different context). Like with this invoice example: In ten years, the data can still be read and the invoice object is the same as it was ten years earlier.

    In other word, Where you must need serialization and without it your code will be missing some important feature.

    That was one example. It's not that you always needs that, but if things become more complex, serialization can be helpful.

提交回复
热议问题