mirror of
https://github.com/php/doc-de.git
synced 2026-03-23 23:02:13 +01:00
134 lines
3.8 KiB
XML
134 lines
3.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: f94d903985119d3ac00f4528551df947f57b667f Maintainer: sammywg Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<!-- Rev-Revision: 65782e9ec67361638f95b2c99648d9954c0dcdc2 Reviewer: samesch -->
|
|
<reference xml:id="class.serializable" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
<title>Das Serializable-Interface</title>
|
|
<titleabbrev>Serializable</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<!-- {{{ Serializable intro -->
|
|
<section xml:id="serializable.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
Interface für benutzerdefiniertes Serialisieren.
|
|
</para>
|
|
|
|
<para>
|
|
Die Klassen, die dieses Interface implementieren, unterstützen
|
|
<link linkend="object.sleep">__sleep</link> und
|
|
<link linkend="object.wakeup">__wakeup</link> nicht mehr. Die Methode
|
|
serialize wird immer aufgerufen, wenn eine Instanz serialisiert werden
|
|
muss. Dabei wird weder __destruct() aufgerufen noch irgend ein anderer
|
|
Nebeneffekt erzeugt, es sei denn, ein solcher wird in der Methode
|
|
serialize explizit erzeugt. Wenn die Daten deserialisiert werden, ist die
|
|
Klasse bekannt und die passende unserialize()-Methode wird anstelle des
|
|
Konstruktors __construct() aufgerufen. Falls notwendig, kann der
|
|
Standardkonstruktor innerhalb von unserialize() aufgerufen werden.
|
|
</para>
|
|
|
|
<warning>
|
|
<para>
|
|
Seit PHP 8.1.0 erzeugt eine Klasse, die
|
|
<interfacename>Serializable</interfacename> implementiert, ohne
|
|
gleichzeitig auch <link linkend="object.serialize">__serialize()</link>
|
|
und <link linkend="object.unserialize">__unserialize()</link> zu
|
|
implementieren, eine Deprecated- (veraltet) Warnung.
|
|
</para>
|
|
</warning>
|
|
</section>
|
|
<!-- }}} -->
|
|
|
|
<section xml:id="serializable.synopsis">
|
|
&reftitle.interfacesynopsis;
|
|
|
|
<!-- {{{ Synopsis -->
|
|
<classsynopsis class="interface">
|
|
<oointerface>
|
|
<interfacename>Serializable</interfacename>
|
|
</oointerface>
|
|
|
|
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
|
|
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.serializable')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='Serializable'])">
|
|
<xi:fallback/>
|
|
</xi:include>
|
|
</classsynopsis>
|
|
<!-- }}} -->
|
|
|
|
</section>
|
|
|
|
<section xml:id="serializable.examples">
|
|
&reftitle.examples;
|
|
<example xml:id="serializable.example.basic"><!-- {{{ -->
|
|
<title>Grundlegende Verwendung</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class obj implements Serializable {
|
|
private $data;
|
|
public function __construct() {
|
|
$this->data = "Meine private-Daten";
|
|
}
|
|
public function serialize() {
|
|
return serialize($this->data);
|
|
}
|
|
public function unserialize($data) {
|
|
$this->data = unserialize($data);
|
|
}
|
|
public function getData() {
|
|
return $this->data;
|
|
}
|
|
}
|
|
|
|
$obj = new obj;
|
|
$ser = serialize($obj);
|
|
|
|
var_dump($ser);
|
|
|
|
$newobj = unserialize($ser);
|
|
|
|
var_dump($newobj->getData());
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
string(42) "C:3:"obj":27:{s:19:"Meine private-Daten";}"
|
|
string(19) "Meine private-Daten"
|
|
]]>
|
|
</screen>
|
|
</example><!-- }}} -->
|
|
</section>
|
|
|
|
|
|
</partintro>
|
|
|
|
&language.predefined.serializable.serialize;
|
|
&language.predefined.serializable.unserialize;
|
|
|
|
</reference>
|
|
<!-- 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
|
|
-->
|