Bugs php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login

go to bug id or search bugs for

Bug #35933 URL rewriting fails on ob_get_contents()
Submitted: 2006年01月08日 17:46 UTC Modified: 2006年01月08日 18:42 UTC
From: ernest at vogelsinger dot at Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.1.1 OS: any
Private report: No CVE-ID: None
[2006年01月08日 17:46 UTC] ernest at vogelsinger dot at
Description:
------------
URL Rewriting fails on ob_get_contents().
Note: the workaround is to have second buffering envelope which gets flushed into the first, thus triggering the URL rewrite. The two lines necessary for the workaround are commented out in the code example.
Reproduce code:
---------------
<?php
$output = <<<EOF
<html><body>
<a href=".">self link</a>
</body></html>
EOF;
ob_start();
// *** ob_start();
session_start();
echo $output;
// *** ob_end_flush();
$data = ob_get_contents();
ob_end_clean();
echo '<xmp>';
if (defined('SID'))
	echo 'URL should be rewritten having: ', SID, "\n";
else
	echo "No SID, no rewritten URL\n";
echo "<xmp>$data</xmp>";
?>
Expected result:
----------------
URL should be rewritten having: PHPSESSID=667e6b2bde474a2820c8e0f8dc41200f
<html><body>
<a href=".?PHPSESSID=667e6b2bde474a2820c8e0f8dc41200f">self link</a> </body></html>
Actual result:
--------------
URL should be rewritten having: PHPSESSID=667e6b2bde474a2820c8e0f8dc41200f
<html><body>
<a href=".">self link</a> </body></html>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
[2006年01月08日 17:51 UTC] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
[2006年01月08日 18:42 UTC] ernest at vogelsinger dot at
Thanks for your omments that this is not a bug - IMHO it is actually a bug, not a feature.
URL rewriting should happen at the final stage, when the output is actually flushed back to the client, not at any other obscure location within the PHP output buffers.
---
I'll post a comment on the respective manual page (which I have read and fully understood ;->)
PHP Copyright © 2001-2025 The PHP Group
All rights reserved. Last updated: Thu Oct 16 03:00:01 2025 UTC

AltStyle によって変換されたページ (->オリジナル) /