Show HTML but don't send headers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Show HTML but don't send headers

Post by tecktalkcm0391 »

I need something like this

Code: Select all

<?php 
ob_start();

?>
//HTML GOES HERE

<?php
//more PHP
 ?>

//HTML GOES HERE

<?php
//more PHP

ob_flush(); 
?>
But I need it to not send headers or anything until it gets to the ob_flush(); how can i do this with still being to edit this page in WYSIWYG formate.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I'm not sure how this normally works... does apache send some headers before PHP has finished working? Do you mind if I ask why you need to do this so that we can maybe try to tackle the problem from a few different angles.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Show HTML but don't send headers

Post by Christopher »

As I have mentioned to you before, you need to start putting your presentation stuff in external template files. Then you can do:

Code: Select all

<?php 
// this is the PHP code that deals with the request and decides what to do

// this is the PHP code that gets and process any data necessary for this page

// this is the PHP code that set vars that wiil be used in the template

ob_start();

include 'mytemplate2.php';    // this is the HTML and presentation related PHP code

ob_flush(); 
?>
(#10850)
Post Reply