-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathexamples.xml
More file actions
111 lines (101 loc) · 3.92 KB
/
examples.xml
File metadata and controls
111 lines (101 loc) · 3.92 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
109
110
111
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: e0b70f68d03701ce531be0025af19cdcfe333782 Maintainer: mch Status: ready -->
<!-- Reviewed: no -->
<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>Основы</title>
<para>
<example>
<title>Пример контроля вывода</title>
<programlisting role="php">
<![CDATA[
<?php
ob_start();
echo "Привет\n";
setcookie("cookiename", "cookiedata");
ob_end_flush();
?>
]]>
</programlisting>
</example>
</para>
<para>
В приведённом примере вывод языковой конструкции <function>echo</function>
будет храниться в буфере вывода до вызова
функции <function>ob_end_flush</function>. Тем временем
вызов функции <function>setcookie</function> успешно сохранится в
cookie браузера, не вызывая ошибки (заголовки не получится отправить
в браузер, когда данные уже отправлены).
</para>
</section>
<section xml:id="outcontrol.examples.rewrite">
<title>Перезапись вывода</title>
<para>
Начиная с PHP 7.1.0 функции <function>output_add_rewrite_var</function> и
<function>output_reset_rewrite_vars</function> работают с отдельным буфером вывода,
то есть не работают с буфером вывода <link linkend="ini.session.use-trans-sid">
прозрачной поддержки sid</link>.
</para>
<para>
<example>
<title>Пример перезаписи вывода</title>
<programlisting role="php">
<![CDATA[
<?php
// Этот код работает с PHP 7.1.0, 7.0.10, 5.6.25 и выше.
// HTTP_HOST — целевой хост по умолчанию. Зададим, чтобы код примера заработал.
$_SERVER['HTTP_HOST'] = 'php.net';
// Обработчик перезаписи вывода перезаписывает только «form». Добавим a=href.
// Теги должны быть указаны как tag_name=url_attr, то есть img=src,iframe=src
// Пробелы между настройками не разрешены.
// Тег «form» — тег, который добавляет скрытые поля «input»
ini_set('url_rewriter.tags','a=href,form=');
var_dump(ini_get('url_rewriter.tags'));
// Это будет добавлено в URL и «form»
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>
С PHP 7.1.0 у функций перезаписи вывода появились отдельные INI-настройки —
<link linkend="ini.url-rewriter.tags">url_rewriter.tags</link>
и <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
-->