<?php
//variables.txt
$name = 'Loretta';
$age = '27';
?>
<?phpThis works just fine. Basically the server replaces your include ''; line with the code from the file, so it actually processes this:
//report.php
include 'variables.txt';
// or you can use the full path; include 'http://www.yoursite.com/folder/folder2/variables.txt';
print $name . " is my name and I am " . $age . " years old.";
?>
<?php
//report.php//variables.txt
$name = 'Loretta';
$age = '27';
// or you can use the full path; include 'http://www.yoursite.com/folder/folder2/variables.txt
print $name . " is my name and I am " . $age . " years old.";
?>
It is important to note that even if you are including a non.php file, if your includes contain PHP code you must have the <?php ?> tags or it will not be processed as PHP. For example, our variables.txt file above included PHP tags. Try saving the file again without them and then run report.php:
//variables.txt
$name = 'Loretta';
$age = '27';
As you can see this does not work. Since you need the <?php ?> tags anyway, and any code in a .txt file can be viewed from a browser (.php code can not,) I would suggest just naming your files with the .php extension to begin with.

