php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36698 headers_sent() returns FALSE when script SSI-included
Submitted: 2006-03-11 15:41 UTC Modified: 2006-03-20 23:33 UTC
From: evilcart at gmail dot com Assigned:
Status: Not a bug Package: Apache related
PHP Version: 4.4.2 OS: FreeBSD 5.0 Release
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: evilcart at gmail dot com
New email:
PHP Version: OS:

 

 [2006-03-11 15:41 UTC] evilcart at gmail dot com
Description:
------------
I'm using PHP-script as part of the page by including it in some middle part of the page (e.g. after some HTML code) using Apache SSI directive <!--#include ... --> 

So when headers_sent() is called before any script output it returns FALSE instead of TRUE. Also, header() function called immideately after that does nothing and executes silently.

As I can understand, any HTML code send before SSI #include of script must set headers_sent() to TRUE.

I have no any errors suppressed on my php.ini file or by other control directives.

Reproduce code:
---------------
page.shtml file (simplified):
<html>
<body>
<!--#include vurtual="./script.php?$QUERY_STRING" -->
</body>
</html>

script.php file (simplified):
<?php
$location = "/some/path/";
if( headers_sent() ) {
	echo "<script language="JavaScript"> window.location.href = '" . $location . "'</sctipt>";
}
else {
	header('Location: '.$location);
	// execution goes HERE! And no any effect or error messages.
}
?>

Expected result:
----------------
<html>
<body>
<script language="JavaScript"> window.location.href = '/some/path/'; </sctipt>
</body>
</html>


Actual result:
--------------
<html>
<body>

</body>
</html>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-11 20:50 UTC] judas dot iscariote at gmail dot com
what happends if you use CORRECT syntax ?

<!--#include virtual="./script.php?$QUERY_STRING" -->


NOT

<!--#include vurtual="./script.php?$QUERY_STRING" -->

???
 [2006-03-12 10:35 UTC] evilcart at gmail dot com
It's just mistprint, excuse me. Of course, I'm using correct syntax in any working examples.

There is also must be </script> instead of </sctipt> printed above, but it doesn't matter, you may instert any code to that output.
 [2006-03-20 23:33 UTC] tony2001@php.net
"virtual" does subrequest, i.e. does almost the same as include("http://...").
No bug here.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 02:01:34 2025 UTC