-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathexamples.xml
111 lines (99 loc) · 3.57 KB
/
examples.xml
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
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: e0b70f68d03701ce531be0025af19cdcfe333782 Maintainer: takagi Status: ready -->
<!-- CREDITS: shimooka,hirokawa -->
<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 "Hello\n";
setcookie("cookiename", "cookiedata");
ob_end_flush();
?>
]]>
</programlisting>
</example>
</para>
<para>
上記の例では、<function>echo</function> からの出力は、
<function>ob_end_flush</function> がコールされるまで出力バッファに
保存されます。この際、
<function>setcookie</function>をコールするとエラーを発生することな
くクッキーが保存されます (通常、データの送信後はブラウザにヘッダ
を送信することはできません)。
</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">透過的セッションID</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';
// 出力リライトはフォームだけを書き換えます。a=href を追加します。
// タグは tag_name=url_attr 形式で指定します。たとえば img=src,iframe=src のようになります。
// 各設定の間にスペースを含めることはできません。
// form タグは特別なタグで、hidden を追加します。
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
-->