Pass a variable from the source file to an included file in PHP
- by Alpha1
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.