note 60483 added to function.ob-start
| From: | ernest at vogelsinger dot at | Date: | Sun, 08 Jan 2006 17:57:42 +0000 |
| Subject: | note 60483 added to function.ob-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101417@lists.php.net to get a copy of this message | ||
When you rely on URL rewriting to pass the PHP session ID you should be careful with
ob_get_contents(), as this might disable URL rewriting completely.
Example:
ob_start();
session_start();
echo '<a href=".">self link</a>';
$data = ob_get_contents();
ob_end_clean();
echo $data;
In the example above, URL rewriting will never occur. In fact, rewriting would occur if you ended
the buffering envelope using ob_end_flush(). It seems to me that rewriting occurs in the very same
buffering envelope where the session gets started, not at the final output stage.
If you need a scenario like the one above, using an "inner envelope" will help:
ob_start();
ob_start(); // add the inner buffering envelope
session_start();
echo '<a href=".">self link</a>';
ob_end_flush(); // closing the inner envelope will activate URL rewriting
$data = ob_get_contents();
ob_end_clean();
echo $data;
In case you're interested or believe like me that this is rather a design flaw instead of a
feature, please visit bug #35933 (http://bugs.php.net/bug.php?id=35933) and comment on it.
----
Manual Page -- http://www.php.net/manual/en/function.ob-start.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60483
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60483&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60483&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60483&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60483&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60483&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60483&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60483&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60483&report=yes
Search -- http://master.php.net/manage/user-notes.php