PHP includes

KenWood

Guppy
Hey I'm new and just like homer thinks thee internets is great!!

anywho i have this include file that isn't getting its variables from the main page, everything is working okay, the include file is being posted, it's just this variable isn't getting its value from the main index page, the page goes like this

$the_header .= "\t<title>".$title."</title>\n";

this is a general html title section, and i want this variable to be recieve its value from index.html, the page to be included, why is it not?

<?php
$title = "Ken Wood";
$image = "sample1.gif";
//Includes html header and footer file
include("includes/headers_footers.php");
//print header
print (html_header());
 
can you give a little more code?

are you calling the include AFTER the title?

Take out the "." From

$the_header .= "\t<title>".$title."</title>\n";
 
Hey, thanks for the reply, heres the header function, maybe its not reading the variable from the index page to the include page, because of the internal function

function html_header()
{
$the_header = "<?xml version='1.0' encoding='iso-8859-1'?>\n";
//$the_header .= $title1 = $title;
$the_header .= "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'\n";
$the_header .= "\t'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n";
$the_header .= "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n";
$the_header .= "<head>\n";
$the_header .= "\t<title>$title</title>\n";
$the_header .= "<link rel='stylesheet' href='css.css' />";
$the_header .= "</head>\n";
$the_header .= "<body>\n";
$the_header .= "<!--Main Table-->\n";
$the_header .= "<table border='1' bordercolor='#000000' cellpadding='0' cellspacing='0' width='700' align='center' bgcolor='FFFFFF'>\n";
$the_header .= "<tr>\n";
$the_header .= "<td>\n";
return $the_header;
}


Here's where i call the function header, this is where it doesnt read the variable title

<?php
$title = "Ken Wood";
$image = "sample1.gif";
$link = "images/";

//Includes html header and footer file
include("includes/headers_footers.php");

//print header
print (html_header());

Thanks!
 
why dont you put the print line into the include page? then you dont have to worry about transferring variables between files.
 
Back
Top