PHP | output_add_rewrite_var() Function
The output_add_rewrite_var() function is an inbuilt function in PHP which is used as output control functions to add values of URL rewritter. This function adds another name or value pair to the URL rewrite mechanism. The name and value will be added to URLs (as GET parameter) and forms (as hidden input fields) the same way as transparent URL rewriting is enabled with session.use_trans_sid instead of session ID. The behaviour of this function is controlled by url_rewriter.tags and url_rewriter.hosts php.ini parameters. In further version dedicated output buffer is used, url_rewriter.tags is used solely for output functions, url_rewriter.hosts is added. Note: Calling 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 variable in string format.
Return Value: This function returns TRUE on success and FALSE on failure. 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"> GeeksforGeeks </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
Please Login to comment...