Pass a variable from the source file to an included file in PHP
Posted
by Alpha1
on Stack Overflow
See other posts from Stack Overflow
or by Alpha1
Published on 2010-06-18T11:57:15Z
Indexed on
2010/06/18
12:03 UTC
Read the original article
Hit count: 207
For my website I want to store the general format of the site in a single PHP file in a single location, and each of the different pages content in the local location of the page. I then want to pass the title and content address to the included file via a variable.
However I can't get the included format file to read the variables storing the title and content data.
AKA, the called file for the individual page would be:
<?php
$title = 'Some Title';
$source_file = 'content.php';
readfile('http:...../format.php');
?>
The format file would be:
<html> ...
<title>
<?php
echo $title;
?>
</title>
...
<?php
include($source_file);
?>
...
I recall reading somewhere I need to include something to get the variables at the start of the format file, however I can't remember what it is or find where I found that information.
© Stack Overflow or respective owner