|
|
|
Description
Description
</H2
><DIV
CLASS="funcsynopsis"
><A
NAME="AEN44407"
></A
><P
></P
><P
><CODE
><CODE
CLASS="FUNCDEF"
>mixed <B
CLASS="function"
>unserialize</B
></CODE
> (string str)</CODE
></P
><P
></P
></DIV
><P
> <B
CLASS="function"
>unserialize()</B
> takes a single serialized
variable (see <A
HREF="get_example.php3?Function=serialize"
><B
CLASS="function"
>serialize()</B
></A
>) and converts it
back into a PHP value. The converted value is returned, and can
be an <SPAN
CLASS="type"
>integer</SPAN
>, <SPAN
CLASS="type"
>double</SPAN
>,
<SPAN
CLASS="type"
>string</SPAN
>, <SPAN
CLASS="type"
>array</SPAN
> or <SPAN
CLASS="type"
>object</SPAN
>.
If an object was serialized, its methods are not preserved in the
returned value.
</P
><P
> <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN44422"
></A
><P
><B
>Example 1. <B
CLASS="function"
>Unserialize()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
> // Here, we use unserialize() to load session data from a database
// into $session_data. This example complements the one described
// with <A
HREF="get_example.php3?Function=serialize"
><B
CLASS="function"
>serialize()</B
></A
>.
$conn = odbc_connect ("webdb", ", "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();
}
}
</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
</P
></DIV
>
|
|
| Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET Categories : Algorithms, HTML and PHP, PHP, Variables | | | clearing variables in php3 Categories : Variables, Arrays, PHP | | | A simple function to prevent undefined $_POST/$_GET/$_SESSION variable errors Categories : PHP, Variables, Errors and Logging | | | This functions compares the current PHP version with a
desired version. Because of the 3 tiered version system, a
direct compare of a string to phpversion() will not be
accurate. Categories : PHP Configuration, PHP, Variables | | | How to control the number of decimal places when outputting numbers. Categories : PHP, Strings, Variables | | | Functions to read a template file and fill in PHP variables. It will also fill in array variables, displaying parts of the template multiple times.
Categories : PHP, Variables, Filesystem | | | Newbie Notes #5 - To double quote, or single quote, that is the question Categories : PHP, Beginner Guides, Variables | | | A quick way set data from a form to a function or other places where you can lose scope. Categories : PHP, HTML and PHP, Variables | | | Display variables when a form is submitted using POST/GET Categories : PHP, Functions, Variables, Debugging | | | Accessing GET and PUT variables with HTTP_GET_VARS on Win2K. Categories : PHP, Windows 2000, Variables | | | Pageinfo: Array containing page URI, page query string (parameters), request method (GET or POST) and the complete URI Categories : Variables, PHP Options and Info, Arrays, URLs, PHP | | | How to implement a session tracking system. Categories : PHP, Sessions, Variables | | | serialize -- Generates a storable representation of a value Categories : PHP, PHP Functions, Variables | | | Variable serialization and unserialization. Loading and saving variable structures
to and from file. Categories : Arrays, Filesystem, Variables, Strings, PHP | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | |
|
|
|