View Full Version : Include within a Variable?
Nickeh32
03-01-2005, 02:26 PM
I'm trying to set a variable that's another file, i'm trying to include it but it just put's the include at the top of the page not were the variable is.
$v = include('page.php');
This is what i did, what am i doing wrong can anyone help?
Also bearing in mind the variable is in the template!
Zero Tolerance
03-01-2005, 02:52 PM
The include() function does not return a value, it would be best if you made page.php build up a variable, and then require() the file, after doing that you can then call the variable it has made :)
Quick Example:
FILE: page.php
<?php
$myvar = "Hello World!";
?>
FILE index.php
<?php
require_once("page.php");
echo $myvar;
?>
Hope that helps :)
- Zero Tolerance
Nickeh32
03-01-2005, 02:59 PM
Well as i said the the variable is in the template and i can't seem to enter PHP into it so i need to set the variable value as the other page!
I'm no good with PHP so i hope you can unserstand that.
and page.php is not relational to the forum it can't really be edited!
Link14716
03-01-2005, 07:29 PM
Your example is this:
$v = include('page.php');
To achieve this affect, use this:
ob_start();
include('page.php');
$v = ob_get_contents();
ob_end_clean();
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.