Output rewrite usage
Since PHP 7.1.0, output_add_rewrite_var(), output_reset_rewrite_vars() use dedicated output buffer. i.e. It does not use trans sid output buffer.
Example #1 Output rewrite example
<?php
// This code works with PHP 7.1.0, 7.0.10, 5.6.25 and up.
// HTTP_HOST is default target host. Set manually to make sample code works.
$_SERVER['HTTP_HOST'] = 'php.net';
// Output rewriter only rewrite form. Add a=href.
// Tags can be specified tag_name=url_attr, e.g. img=src,iframe=src
// No space allowed between settings.
// Form tag is special tag that add hidden input.
ini_set('url_rewriter.tags','a=href,form=');
var_dump(ini_get('url_rewriter.tags'));
// This is added to URL and form
output_add_rewrite_var('test', 'value');
?>
<a href="https://www.gaudry.be/en/php-rf-//php.net/index.html?bug=1234">bug1234</a>
<form action="https://php.net/?bug=1234&edit=1" action="post">
<input type="text" name="title" />
</form>
The above example will output:
<a href="//php.net/?bug=1234&test=value">bug1234</a> <form action="https://php.net/?bug=1234&edit=1" method="post"><input type="hidden" name="test" value="value" /> <input type="text" name="title" /> </form>
Since PHP 7.1.0, output rewrite functions have it's own INI settings, url_rewriter.tags and url_rewriter.hosts.
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-outcontrol.examples.rewrite.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.