PHP output_reset_rewrite_vars() Function

What is PHP output_reset_rewrite_vars() function?

output_reset_rewrite_vars() function resets the URL rewriter and removes all the rewrite variables that were set by the output_add_rewrite_vars() function.

This function will not remove the variables that are part of the script.

Syntax:

output_reset_rewrite_vars()

Parameters:

This function has no parameters.

Return Values:

The function returns-

  • TRUE on success.
  • FALSE on failure.

Examples:

Example 1:

<?php
output_add_rewrite_var('user_id', 'USESS0921');
?>
<a href="confirm.php?act=TRUE">Click</a>
<form action="#" method="POST">
    <input type="text" name="Name" />
</form>
<?php
output_reset_rewrite_vars();
?>

Output:

The output_reset_rewrite_vars() function will remove the “user_id” variables from the URL as well as the form hidden field. That’s why, you see the link like this- http://localhost/phpexercise/confirm.php?act=TRUE.

Otherwise, if you would take the mouse over the “Click” link, you’d see the link like this – http://localhost/phpexercise/confirm.php?act=TRUE&user_id=USESS0921

Also, in the source code you’d see a new hidden field like this – <input type=”hidden” name=”user_id” value=”USESS0921″>

PHP Version Support:

PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8

Summary: PHP output_reset_rewrite_vars() Function

output_reset_rewrite_vars() is a built-in PHP output control function that you can use to rewriter and removes all the rewrite variables that were set by the output_add_rewrite_vars() function.

Reference:

https://www.php.net/manual/en/function.output-reset-rewrite-vars.php