Miscellaneous Functions Library: Serialize

Source: Internet
Author: User
Keywords PHP Chinese function Manual serialize miscellaneous functions Library
Tags aliyun array function functions html http php php chinese function manual

Serialize

(PHP3 >= 3.0.5, PHP4)

Serialize---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; A representation that produces a stored value

Syntax: String serialize (mixed value)

Description:

Serialize () returns a string containing the byte-stream, represented by value, that can be stored anywhere.

This can be used to store or pass PHP values without losing their form and structure.

Using Unserialize () enables the serialized string to become the original PHP value again. Serialize () can handle the form of integer, double, string, array (faceted), object (the properties of the object will be serialized, but the method will be lose)

Example:

<?php

$session _data contains a multi-dimensional array with session

Information for the current user. We use serialize () to store

It in a database at the end of the request.

$conn = Odbc_connect ("WebDB", "PHP", "chicken");

$stmt = Odbc_prepare ($conn, "UPDATE sessions SET data =? WHERE id =? ");

$sqldata = Array (serialize ($session _data), $PHP _auth_user);

if (!odbc_execute ($stmt, & $sqldata)) {

$stmt = Odbc_prepare ($conn, INSERT into sessions (ID, data) VALUES (?,?));

if (!odbc_execute ($stmt, & $sqldata)) {

/* something went wrong. Bitch, whine and moan. */

}

}

?>

Related Article

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.