reference/outcontrol/examples.xml
e0b70f68d03701ce531be0025af19cdcfe333782
...
...
@@ -2,8 +2,9 @@
2
2
<!-- $Revision$ -->
3
3
<appendix xml:id="outcontrol.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4
4
&reftitle.examples;
5
+

5
6
<section xml:id="outcontrol.examples.basic">
6
-
&reftitle.examples;
7
+
<title>Basic usage</title>
7
8
<para>
8
9
<example>
9
10
<title>Output Control example</title>
...
...
@@ -28,10 +29,59 @@ ob_end_flush();
28
29
would be stored in the output buffer until
29
30
<function>ob_end_flush</function> was called. In the mean time,
30
31
the call to <function>setcookie</function> successfully stored a
31
-
cookie without causing an error. (You can not normally send
32
-
headers to the browser after data has already been sent.)
32
+
cookie without causing an error. (Headers cannot normally be sent
33
+
to the browser after data has already been sent.)
34
+
</para>
35
+
</section>
36
+

37
+
<section xml:id="outcontrol.examples.rewrite">
38
+
<title>Output rewrite usage</title>
39
+
<para>
40
+
Since PHP 7.1.0, <function>output_add_rewrite_var</function>, <function>output_reset_rewrite_vars</function> use dedicated output buffer. i.e. It does not use <link linkend="ini.session.use-trans-sid">trans sid</link> output buffer.
41
+
</para>
42
+
<para>
43
+
<example>
44
+
<title>Output rewrite example</title>
45
+
<programlisting role="php">
46
+
<![CDATA[
47
+
<?php
48
+
// This code works with PHP 7.1.0, 7.0.10, 5.6.25 and up.
49
+

50
+
// HTTP_HOST is default target host. Set manually to make sample code works.
51
+
$_SERVER['HTTP_HOST'] = 'php.net';
52
+

53
+
// Output rewriter only rewrite form. Add a=href.
54
+
// Tags can be specified tag_name=url_attr, e.g. img=src,iframe=src
55
+
// No space allowed between settings.
56
+
// Form tag is special tag that add hidden input.
57
+
ini_set('url_rewriter.tags','a=href,form=');
58
+
var_dump(ini_get('url_rewriter.tags'));
59
+

60
+
// This is added to URL and form
61
+
output_add_rewrite_var('test', 'value');
62
+
?>
63
+
<a href="//php.net/index.php?bug=1234">bug1234</a>
64
+
<form action="https://php.net/?bug=1234&edit=1" method="post">
65
+
<input type="text" name="title" />
66
+
</form>
67
+
]]>
68
+
</programlisting>
69
+
&example.outputs;
70
+
<screen>
71
+
<![CDATA[
72
+
<a href="//php.net/?bug=1234&test=value">bug1234</a>
73
+
<form action="https://php.net/?bug=1234&edit=1" method="post"><input type="hidden" name="test" value="value" />
74
+
<input type="text" name="title" />
75
+
</form>
76
+
]]>
77
+
</screen>
78
+
</example>
79
+
</para>
80
+
<para>
81
+
Since PHP 7.1.0, output rewrite functions have it's own INI settings, <link linkend="ini.url-rewriter.tags">url_rewriter.tags</link> and <link linkend="ini.url-rewriter.hosts">url_rewriter.hosts</link>.
33
82
</para>
34
83
</section>
84
+

35
85
</appendix>
36
86

37
87
<!-- Keep this comment at the end of the file
38
88