output_add_rewrite_var

(PHP 4 >= 4.3.0, PHP 5)

output_add_rewrite_var --  Add URL rewriter values

Description

bool output_add_rewrite_var ( string name, string value )

This function rewrite the URLs and forms with the given variable.

注: This function buffers the output.

例子 1. output_add_rewrite_var() example

<?php
output_add_rewrite_var
('var', 'value');

// a link
echo '<a href="file.php">link</a>';

// a form
echo '<form action="script.php" method="post">
<input type="text" name="var2" />
</form>'
;

print_r(ob_list_handlers());
?>

上例将输出:

<a href="file.php?var=value">link</a>

<form action="script.php" method="post">
<input type="hidden" name="var" value="value" />
<input type="text" name="var2" />
</form>

Array
(
    [0] => URL-Rewriter
)

See also output_reset_rewrite_vars(), ob_flush() and ob_list_handlers().


add a note add a note User Contributed Notes
ng4rrjanbiah at rediffmail dot com
19-Jun-2005 02:41
This function obeys url_rewriter.tags ( http://www.php.net/ref.session#ini.url-rewriter.tags ) configuration and hence can be used to rewrite selected tags.

HTH,
R. Rajesh Jeba Anbiah
qbolec
14-Apr-2005 08:46
I'm using this function in control panel, to append md5(session_id()) to each form and link in this panel. I also check when receiving data in control panel, if it contains this md5. I think it's quite good way to prevent the attack, where the user posts an image to the forum, but instead of image url, it specifies the url to control panel with some instructions. You should also check if the data come from the source you intended (GET or POST?).
konrad DOT meyer AT gNOSPAMmail DOT com
09-Feb-2005 02:21
This function can be very helpful for a survey or registration style set of pages where you need to keep variables from one page to the next. (For example, when you mess up a registration, it's always nice to have all but the incorrect fields as you entered them. Re-entering tons of fields is tedious on your users.)