(PHP 4, PHP 5, PHP 7)
serialize — 锟斤拷锟斤拷一锟斤拷锟缴存储锟斤拷值锟侥憋拷示
serialize() 锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟剿憋拷示
value
锟斤拷锟街斤拷锟斤拷锟斤拷锟斤拷锟皆存储锟斤拷锟轿何地凤拷锟斤拷
锟斤拷锟斤拷锟斤拷锟节存储锟津传碉拷 PHP 锟斤拷值锟斤拷同时锟斤拷锟斤拷失锟斤拷锟斤拷锟酵和结构锟斤拷
锟斤拷要锟斤拷锟斤拷锟斤拷锟叫伙拷锟斤拷锟街凤拷锟斤拷锟斤拷锟� PHP 锟斤拷值锟斤拷锟斤拷使锟斤拷 unserialize()锟斤拷serialize() 锟缴达拷锟斤拷锟斤拷锟� resource 之锟斤拷锟斤拷魏锟斤拷锟斤拷汀锟斤拷锟斤拷锟斤拷锟斤拷锟� serialize() 锟斤拷些锟斤拷锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟矫碉拷锟斤拷锟介。锟斤拷锟斤拷 serialize() 锟斤拷锟斤拷锟介/锟斤拷锟斤拷锟叫碉拷锟斤拷锟斤拷也锟斤拷锟斤拷锟芥储锟斤拷
锟斤拷锟斤拷锟叫伙拷锟斤拷锟斤拷时锟斤拷PHP 锟斤拷锟斤拷图锟斤拷锟斤拷锟叫讹拷锟斤拷之前锟斤拷锟矫该讹拷锟斤拷某锟皆憋拷锟斤拷锟� __sleep()锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷诒锟斤拷锟斤拷谢锟街帮拷锟斤拷魏锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟狡的o拷锟斤拷使锟斤拷 unserialize() 锟街革拷锟斤拷锟斤拷时锟斤拷 锟斤拷锟斤拷锟斤拷 __wakeup() 锟斤拷员锟斤拷锟斤拷锟斤拷
Note:
锟斤拷 PHP 3 锟叫o拷锟斤拷锟斤拷锟斤拷锟皆斤拷锟斤拷锟斤拷锟叫伙拷锟斤拷锟斤拷锟角凤拷锟斤拷锟斤拷岫э拷锟絇HP 4 锟斤拷锟斤拷锟剿达拷锟斤拷锟狡o拷锟斤拷锟斤拷同时锟芥储锟斤拷锟皆和凤拷锟斤拷锟斤拷锟斤拷渭锟�锟斤拷锟斤拷锟斤拷锟�锟叫碉拷锟斤拷锟叫伙拷锟斤拷锟斤拷锟斤拷锟街伙拷取锟斤拷锟斤拷锟斤拷息锟斤拷
Example #1 serialize() 示锟斤拷
<?php
// $session_data 锟角帮拷锟斤拷锟剿碉拷前锟矫伙拷 session 锟斤拷息锟侥讹拷维锟斤拷锟介。
// 锟斤拷锟斤拷使锟斤拷 serialize() 锟斤拷锟斤拷锟斤拷锟斤拷锟街帮拷锟斤拷锟芥储锟斤拷锟斤拷锟捷匡拷锟叫★拷
$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)) {
/* 锟斤拷锟斤拷 */
}
}
?>
锟轿硷拷锟斤拷unserialize()锟斤拷