string serialize(mixed value);


Príkaz jazyka PHP
serialize - generates a storable representation of a value

serialize returns a string containing a byte-stream representation of value that can be stored anywhere.

This is useful for storing or passing PHP values around without losing their type and structure.

To make the serialized string into a PHP value again, use unserialize. serialize handles the types integer, double, string, array (multidimensional) and object (object properties will be serialized, but methods are lost).


// $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. */

vytlačiť článok  hľadať súvisiace články 
Vyhľadávanie na stránke
Náhodný obrázok
náhodný obrázok

Martin Kasman, M Software
Smreková 3095/23

Telefón: 0908 270 294