mirror of
https://github.com/php/doc-es.git
synced 2026-04-26 08:38:05 +02:00
d20fadcbae
Sync 40 Spanish translation files with latest English source changes: - context/, wrappers/: bump hashes (role attributes already applied) - control-structures/: indentation and typo fixes - oop5/final: indentation restructure, split note blocks - oop5/property-hooks: add missing property declaration in example - oop5/visibility: add PHP 8.5 asymmetric visibility for static properties - operators/precedence: add pipe operator and throw rows - predefined/attributes: add TARGET_CONSTANT for PHP 8.5 - predefined/closure: add getcurrent entity reference - predefined/*: bump hashes (phpdoc entity changes already applied)
130 lines
3.6 KiB
XML
130 lines
3.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 4d17b7b4947e7819ff5036715dd706be87ae4def Maintainer: PhilDaiguille Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<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>La interfaz Serializable</title>
|
|
<titleabbrev>Serializable</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
<!-- {{{ Serializable intro -->
|
|
<section xml:id="serializable.intro">
|
|
&reftitle.intro;
|
|
<para>
|
|
Interfaz que permite personalizar la serialización.
|
|
</para>
|
|
|
|
<para>
|
|
Las clases que implementan esta interfaz ya no soportan
|
|
<link linkend="object.sleep">__sleep()</link> y
|
|
<link linkend="object.wakeup">__wakeup()</link>.
|
|
El método de serialización es llamado cada vez que una
|
|
instancia debe ser serializada. No llama al método
|
|
__destruct() y no tiene ningún efecto sobre el contenido de este método.
|
|
Cuando los datos son serializados, la clase es conocida y
|
|
el método unserialize() apropiado es llamado como constructor
|
|
en lugar de llamar a __construct(). Si es necesario llamar al constructor
|
|
estándar, se puede hacer en el método.
|
|
</para>
|
|
|
|
<warning>
|
|
<para>
|
|
A partir de PHP 8.1.0, una clase que implemente <interfacename>Serializable</interfacename>
|
|
sin también implementar <link linkend="object.serialize">__serialize()</link>
|
|
y <link linkend="object.unserialize">__unserialize()</link> generará
|
|
una advertencia de deprecación.
|
|
</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>Ejemplo simple</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:19:"Mis datos privados";}"
|
|
string(19) "Mis datos privados"
|
|
]]>
|
|
</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
|
|
-->
|