-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathexamples.xml
More file actions
108 lines (96 loc) · 3.37 KB
/
examples.xml
File metadata and controls
108 lines (96 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: e0b70f68d03701ce531be0025af19cdcfe333782 Maintainer: PhilDaiguille Status: ready -->
<!-- Reviewed: yes -->
<appendix xml:id="outcontrol.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="outcontrol.examples.basic">
<title>Uso básico</title>
<para>
<example>
<title>Ejemplo de bufferización de salida</title>
<programlisting role="php">
<![CDATA[
<?php
ob_start();
echo "Bonjour\n";
setcookie("cookiename", "cookiedata");
ob_end_flush();
?>
]]>
</programlisting>
</example>
</para>
<para>
En el ejemplo anterior, la instrucción
<function>echo</function>
se almacena en un buffer hasta la llamada a la función
<function>ob_end_flush</function>. Al mismo tiempo, la llamada a <function>setcookie</function> ha tenido éxito en la creación de un cookie, sin generar errores.
(Normalmente, los encabezados deben enviarse al navegador antes de los datos).
</para>
</section>
<section xml:id="outcontrol.examples.rewrite">
<title>Uso de la reescritura de salida</title>
<para>
Desde PHP 7.1.0, <function>output_add_rewrite_var</function>, <function>output_reset_rewrite_vars</function> utiliza un buffer de salida dedicado. Es decir, no utiliza un buffer de salida <link linkend="ini.session.use-trans-sid">trans sid</link>.
</para>
<para>
<example>
<title>Ejemplo de reescritura de salida</title>
<programlisting role="php">
<![CDATA[
<?php
// Este código funciona con PHP 7.1.0, 7.0.10, 5.6.25 y superior.
// HTTP_HOST es el host objetivo por defecto. Definir manualmente para que el ejemplo de código funcione.
$_SERVER['HTTP_HOST'] = 'php.net';
// La reescritura de salida solo puede reescribir los form. Añadir a=href.
// Las etiquetas pueden especificarse como tag_name=url_attr, por ejemplo img=src, iframe=src
// No se permiten espacios entre los argumentos.
// La etiqueta form es una etiqueta especial que añade un campo oculto.
ini_set('url_rewriter.tags','a=href,form=');
var_dump(ini_get('url_rewriter.tags'));
// Esto se añade a la URL y al formulario
output_add_rewrite_var('test', 'value');
?>
<a href="//php.net/index.php?bug=1234">bug1234</a>
<form action="https://php.net/?bug=1234&edit=1" method="post">
<input type="text" name="title" />
</form>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
<a href="//php.net/?bug=1234&test=value">bug1234</a>
<form action="https://php.net/?bug=1234&edit=1" method="post"><input type="hidden" name="test" value="value" />
<input type="text" name="title" />
</form>
]]>
</screen>
</example>
</para>
<para>
Desde PHP 7.1.0, las funciones de reescritura de salida tienen sus propios parámetros INI, <link linkend="ini.url-rewriter.tags">url_rewriter.tags</link> y <link linkend="ini.url-rewriter.hosts">url_rewriter.hosts</link>.
</para>
</section>
</appendix>
<!-- 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
-->