How to use php serialize() and unserialize()

后端 未结 10 1730
Happy的楠姐
Happy的楠姐 2020-11-22 05:03

My problem is very basic.

I did not find any example to meet my needs as to what exactly serialize() and unserialize() mean in php? They ju

10条回答
  •  心在旅途
    2020-11-22 05:30

    Most storage mediums can store string types. They can not directly store a PHP data structure such as an array or object, and they shouldn't, as that would couple the data storage medium with PHP.

    Instead, serialize() allows you to store one of these structs as a string. It can be de-serialised from its string representation with unserialize().

    If you are familiar with json_encode() and json_decode() (and JSON in general), the concept is similar.

提交回复
热议问题