PHP: Hypertext Preprocessor (original) (raw)
output_add_rewrite_var
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
output_add_rewrite_var — Add URL rewriter values
Description
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 theurl_rewriter.tags andurl_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](reserved.constants.php#constant.true)
on success or [false](reserved.constants.php#constant.false)
on failure.
Changelog
Version | Description |
---|---|
7.1.0 | As of PHP 7.1.0, a dedicated output buffer is used,url_rewriter.tags is used solely for output functions andurl_rewriter.hosts is available. Prior to PHP 7.1.0, rewrite variables set by output_add_rewrite_var() shared an output buffer with transparent session id support (see session.trans_sid_tags). |
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 'link
link2';// a form
echo '
';print_r(ob_list_handlers()); ?>`
The above example will output:
Array ( [0] => URL-Rewriter )
See Also
- output_reset_rewrite_vars() - Reset URL rewriter values
- ob_flush() - Flush (send) the return value of the active output handler
- ob_list_handlers() - List all output handlers in use
- url_rewriter.tags
- url_rewriter.hosts
Found A Problem?
16 years ago
`For a completely valid XHTML document you have to set the arg_separator, use this before you use output-add-rewrite-var:
`
17 years ago
`This function also adds a parameter to fields!
Example:
This code:
will output something like this:
`