Send headers and HTML all at once

This is a discussion on Send headers and HTML all at once within the PHP General forums, part of the PHP Programming Forums category; Hy all, The variable $x contains all data to sent back to the user. Thus all headers and the HTML ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-25-2004
Rob
 
Posts: n/a
Default Send headers and HTML all at once

Hy all,

The variable $x contains all data to sent back to the user. Thus all headers
and the HTML for a HTML page in one variable. How do I send this back to the
client browser?

If I echo/print the data PHP creates its own set of headers and the headers
in $x will be displayed in the browser window instead of sending it as
headers.


Is there any way to send the data in $x al at once so php does not create
its own set of headers?

Thanks in advance
Rob


Reply With Quote
  #2 (permalink)  
Old 11-13-2004
Mike Gatny
 
Posts: n/a
Default Re: Send headers and HTML all at once

<?php
/* Each header should end with CRLF, represented as "\r\n".
* The end of the headers is signified with an additional CRLF,
* often referred to as a "blank line" between headers and document.
* Make sure there are no blank lines before the opening <?php
* tag, else the headers will be sent immediately.
*/

/* $x = your document and headers... */
$res = preg_split('(\r\n)', $x);

$headers_done = false;
for($i = 0; $i < count($res); $i++) {
if($res[$i] == "\r\n") {
$headers_done = true;
}
if($headers_done) {
print $res[$i];
}
else {
header($res[$i]);
}
}
?>
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:57 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0