PHPCon Poland 2024

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

// 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.

// 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.

// This is added to URL and form
output_add_rewrite_var('test', 'value');
<a href="//">bug1234</a>
<form action="" method="post">
<input type="text" name="title" />

The above example will output:

<a href="//">bug1234</a>
<form action="" method="post"><input type="hidden" name="test" value="value" />
 <input type="text" name="title" />

Since PHP 7.1.0, output rewrite functions have it's own INI settings, url_rewriter.tags and url_rewriter.hosts.

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top