Wednesday, November 20, 2024
Google search engine
HomeLanguagesPHP | output_add_rewrite_var() Function

PHP | output_add_rewrite_var() Function

The output_add_rewrite_var() function is an inbuilt function in PHP that is used as an output control functions to add values of URL rewriter. This function adds another name or value pair to the URL rewrite mechanism. The name and value will be added to URLs (as GET parameters) and forms (as hidden input fields) in the same way as transparent URL rewriting is enabled with the session.use_trans_sid instead of the session ID. The behavior of this function is controlled by url_rewriter.tags and url_rewriter.hosts php.ini parameters. In the further version dedicated output buffer is used, url_rewriter.tags is used solely for output functions, and url_rewriter.hosts are added. 

Note: Calling the output_add_rewrite_var() function start output buffering implicitly even if it is not active already. 

Syntax:

bool output_add_rewrite_var( string $name, string $value )

Parameters:

  • $name: It holds the variable name in string format.
  • $value: It holds the value of the variable in string format.

Return Value: This function returns TRUE on success and FALSE on failure. The below programs illustrate the output_add_rewrite_var() function in PHP.

Program 1: 

php




<?php
 
session_start();
output_add_rewrite_var('var', 'value');
  
echo '<a href="file.php">link</a>';
 
echo '<form action="script.php" method="post">
          <input type="text" name="var2" />
      </form>';
 
print_r(ob_list_handlers());
ob_flush();
  
output_reset_rewrite_vars();
 
echo '<a href="file.php">link</a>';
print_r(ob_list_handlers());
 
?>


Output: 

Program 2: 

php




<?php
 
output_add_rewrite_var('var', 'value');
  
// HTML link of web page
echo '<a href="index.php">Home Page Link</a>
<a href="https://www.geeksforgeeks.org">
    neveropen
</a>';
  
// HTML form element
echo '<form action="index.php" method="post">
<input type="text" name="yourname" />
</form>';
  
print_r(ob_list_handlers());
 
?>


Output: 

Reference: https://www.php.net/manual/en/function.output-add-rewrite-var.php

RELATED ARTICLES

Most Popular

Recent Comments