PHP unserialize() 函数

PHP 教程 · 2019-01-31 21:56:55

unserialize() 函数用于将通过 serialize() 函数序列化后的对象或数组进行反序列化,并返回原始的对象结构。

PHP 版本要求: PHP 4, PHP 5, PHP 7

语法

mixed unserialize ( string $str )

参数说明:

  • $str: 序列化后的字符串。

返回值

返回的是转换之后的值,可为 integer、float、string、array 或 object。

如果传递的字符串不可解序列化,则返回 FALSE,并产生一个 E_NOTICE。

实例

实例

<?php $str = 'a:3:{i:0;s:6:"Google";i:1;s:6:"Codercto";i:2;s:8:"Facebook";}'; $unserialized_data = unserialize($str); print_r($unserialized_data); ?>

输出结果为:

Array
(
    [0] => Google
    [1] => Codercto
    [2] => Facebook
)

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

The Haskell School of Expression

The Haskell School of Expression

Paul Hudak / Cambridge University Press / 2000-01 / USD 95.00

Functional programming is a style of programming that emphasizes the use of functions (in contrast to object-oriented programming, which emphasizes the use of objects). It has become popular in recen......一起来看看 《The Haskell School of Expression》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试