PDA

View Full Version : Phpinclude Template


Rostor
02-05-2002, 12:17 PM
I use this code for including header.php page in my vb.

ob_start();
require("swzheader.php");
$header1 = ob_get_contents();
ob_end_clean();


Now I need to include another page swzfooter.php in my vb index, I try some code like this :


ob_start();
require("swzheader.php");
ob_start();
require("swzfooter.php");
$footer1 = ob_get_contents();
ob_end_clean();
$header1 = ob_get_contents();
ob_end_clean();


but it doesn't works any idea ?

Admin
02-05-2002, 06:40 PM
ob_start();
require("swzheader.php");
$header1 = ob_get_contents();
ob_clean();
require("swzfooter.php");
$footer1 = ob_get_contents();
ob_end_clean();
(using ob_clean() to clear the buffer before requiring another file...)

Rostor
02-05-2002, 06:48 PM
It gives me this error:

Fatal error: Call to undefined function: ob_clean() in C:\Inetpub\wwwroot\Forum\global.php(275) : eval()'d code on line 9

just a little more help plz ? :)

Admin
02-05-2002, 06:51 PM
Oh ok, I just noticed that function in not yet in tje PHP release. :) Sorry.

Use this:
// get header
ob_start();
require("swzheader.php");
$header1 = ob_get_contents();
ob_end_clean();

// get footer
ob_start();
require("swzfooter.php");
$footer1 = ob_get_contents();
ob_end_clean();

badr511
02-05-2002, 07:26 PM
number 1 firefly :up:

XiXora
02-05-2002, 09:55 PM
why do we have to use ob things?

Admin
02-06-2002, 06:29 AM
OB = Output Buffering.

Because when you include a file, what it outputs is also output on the including page, and we don't want that, because we want to USE what it output as a variable later in the templates.

So we use output control to 'capture' the output of that file and store it inside a variable.