mirror of
https://github.com/php/doc-es.git
synced 2026-03-25 16:02:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@323008 c90b9560-bf6c-de11-be94-00142212c4b1
127 lines
3.4 KiB
XML
127 lines
3.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: fcddfb2551140fba9a14a4c44dc9fa60004440c8 Maintainer: andresdzphp Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<phpdoc:classref xml:id="class.serializable" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
<title>La interfaz Serializable</title>
|
|
<titleabbrev>Serializable</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<!-- {{{ Serializable intro -->
|
|
<section xml:id="serializable.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
Interfaz para personalizar la serialización.
|
|
</para>
|
|
|
|
<para>
|
|
Las clases que implementan esta interfaz no soportan
|
|
<link linkend="object.sleep">__sleep()</link> ni
|
|
<link linkend="object.wakeup">__wakeup()</link>. El método
|
|
serialize se llama cuando una instancia requiere ser serializada. Esto no invoca
|
|
__destruct() ni tiene ningún efecto adicional a menos que se programe dentro
|
|
del método. Cuando los datos son deserializados, la clase es conocida y el
|
|
correspondiente método unserialize() es llamado como constructor en lugar de llamar al
|
|
método __construct(). Se puede ejecutar el constructor estándar en el método si
|
|
fuera necesario.
|
|
</para>
|
|
</section>
|
|
<!-- }}} -->
|
|
|
|
<section xml:id="serializable.synopsis">
|
|
&reftitle.interfacesynopsis;
|
|
|
|
<!-- {{{ Synopsis -->
|
|
<classsynopsis>
|
|
<ooclass><classname>Serializable</classname></ooclass>
|
|
|
|
<!-- {{{ Class synopsis -->
|
|
<classsynopsisinfo>
|
|
<ooclass>
|
|
<classname>Serializable</classname>
|
|
</ooclass>
|
|
</classsynopsisinfo>
|
|
<!-- }}} -->
|
|
|
|
<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[1])" />
|
|
</classsynopsis>
|
|
<!-- }}} -->
|
|
|
|
</section>
|
|
|
|
<section xml:id="serializable.examples">
|
|
<example xml:id="serializable.example.basic"><!-- {{{ -->
|
|
<title>Uso básico</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class obj implements Serializable {
|
|
private $data;
|
|
public function __construct() {
|
|
$this->data = "Mis datos privados";
|
|
}
|
|
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(38) "C:3:"obj":23:{s:15:"Mis datos privados";}"
|
|
string(15) "Mis datos privados"
|
|
]]>
|
|
</screen>
|
|
</example><!-- }}} -->
|
|
</section>
|
|
|
|
|
|
</partintro>
|
|
|
|
&language.predefined.serializable.serialize;
|
|
&language.predefined.serializable.unserialize;
|
|
|
|
</phpdoc:classref>
|
|
|
|
<!-- 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
|
|
-->
|