unserialize

 

Syntax


mixed unserialize(string str);

Popis


Príkaz jazyka PHP
unserialize - creates a PHP value from a stored representation
unserialize takes a single serialized variable (see serialize) and converts it back into a PHP value. The converted value is returned, and can be an integer, double, string, array or object. If an object was serialized, its methods are not preserved in the returned value.

Príklad


// Here, we use unserialize() to load session data from a database
// into $session_data. This example complements the one described
// with serialize.
$conn = odbc_connect("webdb", "php", "chicken");
$stmt = odbc_prepare($conn, "SELECT data FROM sessions WHERE id = ?");
$sqldata = array($PHP_AUTH_USER);
if (!odbc_execute($stmt, &$sqldata) || !odbc_fetch_into($stmt, &$tmp)) {
  // if the execute or fetch fails, initialize to empty array
  $session_data = array();
} else {
  // we should now have the serialized data in $tmp[0].
  $session_data = unserialize($tmp[0]);
  if (!is_array($session_data)) {
    // something went wrong, initialize to empty array
    $session_data = array();
  }
}



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

Martin Kasman, M Software
Smreková 3095/23
Email: martin@kasman.sk

Telefón: 0908 270 294