output_add_rewrite_var
Add URL rewriter values
Description
bool output_add_rewrite_var(string $name
, string $value
)
When the output buffer is flushed
(by calling ob_flush, ob_end_flush,
ob_get_flush or at the end of the script)
the 'URL-Rewriter'
handler adds the name/value pairs
as query parameters to URLs in attributes of HTML tags
and adds hidden fields to forms based on the values of the
url_rewriter.tags and
url_rewriter.hosts
configuration directives.
Each name/value pair added to the 'URL-Rewriter'
handler
is added to the URLs and/or forms
even if this results in duplicate URL query parameters
or elements with the same name attributes.
Note:
Once the 'URL-Rewriter'
handler has been turned off
it cannot be started again.
Parameters
-
name
-
The variable name.
-
value
-
The variable value.
Return Values
Returns true
on success or false
on failure.
Examples
Example #1 output_add_rewrite_var example
<?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());
?>
The above example will output:
<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
)