Home > php教程 > php手册 > body text

PHP serialize与 unserialize实用说明

WBOY
Release: 2016-06-13 11:24:51
Original
851 people have browsed it

serialize — 产生一个可存储的值的表示
unserialize — 从已存储的表示中创建 php教程 的值

想要将已序列化的字符串变回 php 的值,可使用 unserialize()。serialize() 可处理除了 resource 之外的任何类型。甚至可以 serialize() 那些包含了指向其自身引用的数组。你正 serialize() 的数组/对象中的引用也将被存储。

*/
serialize

//store data:
$array = explode('rn', $string);
$serialized = serialize($array);

//restore data:
$array = unserialize($serialized);
$text = implode('rn', $array);


unserialize
function restorepost() {
    if (isset($_post[savepost])) {
        $_post = unserialize(strips教程lashes(htmlspecialchars_decode($_post[savepost])));
    }
}


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!