Serailization & Unserialization in PHP

Serialization which help us to store or transport PHP data structure such as an array or object. All the storage meduim or database can store String type. It will generates a storable representation of a value. This is useful for storing or passing PHP values around without losing their type and structure.

Essentially, it takes a php array or object and converts it to a string (which you can then transmit or store as you see fit).

i.e, 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()  both the concept is similar.

Using Serialize method, We can store multiple field key & its values in single column. You can easily extend your forms without changing table structure.

Permanent link to this article: https://blog.openshell.in/2014/01/serailization-unserialization-in-php/

Leave a Reply

Your email address will not be published.