「PHP Programming/Files」の版間の差分

Serialization is a technique used by programmers to preserve their working data in a format that can later be restored to its previous form. In simple cases this means converting a normal variable such as an array into a string and then storing it somewhere. That data can then be unserialized and the programmer will be able to work with the array once again.
 
There is a whole chapter devoted to [[Programming:PHP/Serialization|Serialization]] in this book as it is a useful technique to know how to use effectively. It is mentioned here as one of the primary uses of serialization is to store data on plain files when a database is not available. It is also used to store the state of a script and to cache data for quicker access later and files are one of the preferred media for this storage.
 
In PHP, serialization is very easy to perform through use of the [http://php.net/serialize serialize()] and [http://php.net/unserialize unserialize()] functions. Here follows an example of serialization used in conjunction with file functions.
匿名利用者