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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.output-add-rewrite-var">
<refnamediv>
<refname>output_add_rewrite_var</refname>
<refpurpose>Add URL rewriter values</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>output_add_rewrite_var</methodname>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
<methodparam><type>string</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
This function starts the <literal>'URL-Rewriter'</literal> output buffer handler
if it is not active,
stores the <parameter>name</parameter> and <parameter>value</parameter> parameters,
and when the buffer is flushed rewrites the <acronym>URL</acronym>s
and forms based on the applicable ini settings.
Subsequent calls to this function will store all additional name/value pairs
until the handler is turned off.
</para>
<para>
When the output buffer is flushed
(by calling <function>ob_flush</function>, <function>ob_end_flush</function>,
<function>ob_get_flush</function> or at the end of the script)
the <literal>'URL-Rewriter'</literal> handler adds the name/value pairs
as query parameters to <acronym>URL</acronym>s in attributes of HTML tags
and adds hidden fields to forms based on the values of the
<link linkend="ini.url-rewriter.tags">url_rewriter.tags</link> and
<link linkend="ini.url-rewriter.hosts">url_rewriter.hosts</link>
configuration directives.
</para>
<para>
Each name/value pair added to the <literal>'URL-Rewriter'</literal> handler
is added to the <acronym>URL</acronym>s and/or forms
even if this results in duplicate <acronym>URL</acronym> query parameters
or elements with the same name attributes.
</para>
<note>
<simpara>
Once the <literal>'URL-Rewriter'</literal> handler has been turned off
it cannot be started again.
</simpara>
</note>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
The variable name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The variable value.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.1.0</entry>
<entry>
As of PHP 7.1.0, a dedicated output buffer is used,
<link linkend="ini.url-rewriter.tags">url_rewriter.tags</link>
is used solely for output functions and
<link linkend="ini.url-rewriter.tags">url_rewriter.hosts</link> is available.
Prior to PHP 7.1.0, rewrite variables set by <function>output_add_rewrite_var</function>
shared an output buffer with transparent session id support
(see <link linkend="ini.session.trans-sid-tags">session.trans_sid_tags</link>).
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>output_add_rewrite_var</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
ini_set('url_rewriter.tags', 'a=href,form=');
output_add_rewrite_var('var', 'value');
// some links
echo '<a href="file.php">link</a>
<a href="http://example.com">link2</a>';
// a form
echo '<form action="script.php" method="post">
<input type="text" name="var2" />
</form>';
print_r(ob_list_handlers());
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
<a href="file.php?var=value">link</a>
<a href="http://example.com">link2</a>
<form action="script.php" method="post">
<input type="hidden" name="var" value="value" />
<input type="text" name="var2" />
</form>
Array
(
[0] => URL-Rewriter
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>output_reset_rewrite_vars</function></member>
<member><function>ob_flush</function></member>
<member><function>ob_list_handlers</function></member>
<member><link linkend="ini.url-rewriter.tags">url_rewriter.tags</link></member>
<member><link linkend="ini.url-rewriter.hosts">url_rewriter.hosts</link></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- 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
-->
|