Hàm unserialize () trong PHP
Thí dụ
Chuyển đổi dữ liệu được tuần tự hóa trở lại thành dữ liệu thực tế:
<?php
$data = serialize(array("Red", "Green", "Blue"));
echo $data
. "<br>";
$test = unserialize($data);
var_dump($test);
?>
Định nghĩa và Cách sử dụng
Hàm unserialize () chuyển đổi dữ liệu được tuần tự hóa trở lại thành dữ liệu thực tế.
Cú pháp
unserialize(string, options);
Giá trị tham số
Parameter | Description |
---|---|
string | Required. Specifies the serialized string |
options | Optional. Specifies options to be provided to the function, as an associative array. Can be either an array of class names which should be accepted, false to accept no classes, or true to accept all classes. True is default. |
Chi tiết kỹ thuật
Giá trị trả lại: | Giá trị đã chuyển đổi. Có thể là boolean, số nguyên, float, chuỗi, mảng hoặc đối tượng. FALSE và E_NOTICE không thành công |
---|---|
Loại trả lại: | Boolean, số nguyên, float, chuỗi, mảng hoặc đối tượng |
Phiên bản PHP: | 4.0+ |
PHP Changelog: | PHP 7.0: Đã thêm tham số tùy chọn |
❮ Tham chiếu xử lý biến PHP