mirror of
https://github.com/php/doc-it.git
synced 2026-04-24 07:48:20 +02:00
805a9350e0
git-svn-id: https://svn.php.net/repository/phpdoc/it/trunk@300701 c90b9560-bf6c-de11-be94-00142212c4b1
167 lines
4.7 KiB
XML
167 lines
4.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 96c9d88bad9a7d7d44bfb7f26c226df7ee9ddf26 Maintainer: cucinato Status: ready -->
|
|
<refentry xml:id="function.serialize" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>serialize</refname>
|
|
<refpurpose>Genera una versione archiviabile del valore</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>serialize</methodname>
|
|
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Genera una versione archiviabile di un valore
|
|
</para>
|
|
<para>
|
|
Questo è utile per archiviare o passare valori a PHP senza
|
|
perderne il tipo e la struttura.
|
|
</para>
|
|
<para>
|
|
Per ottenere il valore dalla stringa serializzata, utilizzare
|
|
la funzione <function>unserialize</function>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>value</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Il valore da serializzare. <function>serialize</function>
|
|
gestisce tutti i tipi di variabili tranne il tipo <type>resource</type>.
|
|
Possono essere elaborati da <function>serialize</function> array che
|
|
contengano riferimenti a se stessi. Saranno archiviati anche i riferimenti
|
|
circolari negli array/object. Ogni altro
|
|
riferimento verrà perso.
|
|
</para>
|
|
<para>
|
|
Quando si esegue la serializzazione di oggetti, PHP cerca di eseguire la funzione
|
|
<link linkend="language.oop5.magic">__sleep</link> prima di cominciare la serializzazione.
|
|
Questo permette all'oggetto di eseguire le ultime operazioni di chiusura prima
|
|
di essere serializzato. Analogamente, quando l'oggetto viene ripristinato usando
|
|
<function>unserialize</function> viene chiamata la funzione membro <link
|
|
linkend="language.oop5.magic">__wakeup</link>.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
I membri privati dell'oggetto avranno il nome della classe preposto al nome del
|
|
membro; i membri protetti avranno un '*' preposto al nome del membro.
|
|
Questi valori preposti sono delimitati da byte null.
|
|
</para>
|
|
</note>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Restituisce una stringa contenente un flusso di bytes rappresentante
|
|
<parameter>value</parameter> che può essere archiviato ovunque.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Esempio di <function>serialize</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// L'array multi-dimensionale $session_data contiene le informazioni della sessione
|
|
// per l'utente. Si userà serialize() per memorizzare le informazioni
|
|
// all'interno di un database alla fine della richiesta..
|
|
|
|
$conn = odbc_connect("webdb", "php", "chicken");
|
|
$stmt = odbc_prepare($conn,
|
|
"UPDATE sessions SET data = ? WHERE id = ?");
|
|
$sqldata = array (serialize($session_data), $_SERVER['PHP_AUTH_USER']);
|
|
if (!odbc_execute($stmt, $sqldata)) {
|
|
$stmt = odbc_prepare($conn,
|
|
"INSERT INTO sessions (id, data) VALUES(?, ?)");
|
|
if (!odbc_execute($stmt, $sqldata)) {
|
|
/* Qualcosa non ha funzionato... */
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>4.0.7</entry>
|
|
<entry>
|
|
Il processo di serializzazione degli oggetti è stato corretto.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
It is not possible to serialize PHP built-in objects.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>unserialize</function></member>
|
|
<member><link linkend="language.oop5.serialization">Serializing Objects</link></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|