Home >Backend Development >PHP Tutorial >PHP数组序列化与反序列化

PHP数组序列化与反序列化

WBOY
WBOYOriginal
2016-06-23 13:14:391253browse

<?php$nav = array('action' => 'Portal/List/index', 'param' => array('id'=>3));$str = serialize($nav);//序列化$arr = unserialize($str);//反序列化echo $str;print_r($arr);输出:a:2:{s:6:"action";s:17:"Portal/List/index";s:5:"param";a:1:{s:2:"id";i:3;}}Array(	[action] => Portal/List/index	[param] => Array	(		[id] => 3	))序列化是将变量转换为可保存或传输的字符串的过程;反序列化就是在适当的时候把这个字符串再转化成原来的变量使用。这两个过程结合起来,可以轻松地存储和传输数据,使程序更具维护性。


Statement:
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