vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Phpinclude Template (https://vborg.vbsupport.ru/showthread.php?t=34807)

Rostor 02-05-2002 12:17 PM

I use this code for including header.php page in my vb.
PHP Code:

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 :

PHP Code:

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

PHP Code:

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:
PHP Code:

// 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.


All times are GMT. The time now is 07:07 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00983 seconds
  • Memory Usage 1,725KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete