MyBB Community Forums

Full Version: Stop Header Information
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all

I'm trying to include the portal.php in another php file I want to use as the home page..

<? include 'portal.php'; ?>

(all I have in the portal template is the $welcome .. I don't want to use the portal template as the home page as there are other scripts I want to call .. and they don't work from the portal template .. only "$variables" will .. and thats over my head!)

I get this error ...

Warning: Cannot modify header information - headers already sent by (output started at /home/xxxx/xxxx/xxxx.org/public_html/test.php:12) in /home/xxxx/xxxx/xxxx.org/public_html/inc/functions.php on line 849


Can anyone tell me what to edit out in the portal.php to stop it sending
the header info?

I'm using PR2.

Thanx in advance

Big Grin



use output buffering:

ob_start();
//rest of code
You mean like this?

ob_start();
<? include 'portal.php'; ?>

I don't think I get it.

Rolleyes
hey,

now he means to put the code of the portal

Go HERE, to read more about it.

it should looks like this(just an example)

<?php

function callback($buffer) 
{
  // replace all the apples with oranges
  return (str_replace("apples", "oranges", $buffer));
}

ob_start("callback");

?>
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
<?php

ob_end_flush();

?> 

regards
Do a quick google for ob_start();. Wink

It's standard PHP.
It should look something like this:

<?php
ob_start();

// any other code you have
?>
<p>example html</p>

<?php include './portal.php';?>

<p>more html</p>
<?php
// any other code you have
ob_end_flush();
?>


Make sure that the first <?php is at the top of your page, with no extra spaces or empty lines.