Examples of serialize () and unserialize () functions in PHP

Source: Internet
Author: User
PHP's serialize () function and unserialize () function

Context: Serialize () returns a string that contains a byte stream representing value that can be stored anywhere. This facilitates the storage or delivery of PHP values without losing their type and structure. A useful place to put data in a database or in a file. This article mainly and you introduce PHP serialize () function and unserialize () function of the relevant information, the need for friends can refer to, hope to help everyone.

Serialize () handles all types outside of a resource type, and can also serialize an object


<?php $array = Array (); $array [' keys '] = ' www '; $array [' Values ']= ' 11111 '; $a = serialize ($array); echo $a; Unset ($array); $a = unserialize ($a); Print_r ($a);?>

Output


A:2:{s:4: "Keys"; s:3: "www"; s:6: "Values"; s:5: "11111";} Array ([keys] = www [values] = 11111)

The same is true for class operations.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.