Open In App

PHP output_reset_rewrite_vars() Function

Last Updated : 11 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The output_reset_rewrite_vars() is a built-in function in PHP, resets URL rewriter values by removing all rewrite variables previously set through the output_add_rewrite_var() function.

Syntax:

output_reset_rewrite_vars(): bool

Parameter: This function does not accept any parameters.

Return Values: This function returns “true” if successful otherwise it will return “false”.

Program 1: The following is the Illustration of the ouput_reset_rewrite_vars() function.

PHP




<?php
ini_set('url_rewriter.tags', 'a=href,form=');
output_add_rewrite_var('page', 'home');
echo '<a href="index.php">Home</a>';
output_reset_rewrite_vars();   
?>


Output:

Home   

Program 2: The following is the Illustration of the output_reset_rewrite_vars() function.

PHP




<?php
// Make the URL rewriter affect <a href> and <form> tags
ini_set('url_rewriter.tags','a=href,form=');
  
// Add a variable
output_add_rewrite_var('var', 'value');
echo '<a href="">This link (URL) will have a variable</a><br>';
ob_flush();
  
// Remove the variable
output_reset_rewrite_vars();
echo '<a href="">This link (URL) will not have a variable</a>';    
?>


Output:

This link (URL) will have a variable
This link (URL) will not have a variable

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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads