Including a php file
Example PHP file:
www.yourdomain.com/myfiles/file.php
{source}<?php
require_once JPATH_SITE.'/myfiles/file.php';
?>{/source}
include/require vs require_once
You can also use 'include' (or 'require') instead of 'require_once', but only use that if you need the file included more than once on your page.
If your php file creates classes / functions, having it included more than once will cause errors like "Cannot redeclare class".
Setting variables for a php file
If you want to set variables that are used in the php file, you can simply set them before the require/include, like:
{source}<?php
$name = 'Peter';
$surname = 'van Westen';
$interests = array( 'small fluffy things', 'green cantaloupe', 'toothpaste', '9V batteries' );
require_once JPATH_SITE.'/myfiles/file.php';
?>{/source}
Including a text file
For text files, like .txt or .html you could use this syntax:
{source}<?php
echo file_get_contents( JPATH_SITE.'/myfiles/file.txt' );
?>{/source}
NO html structures
Please keep in mind that files you include do NOT generate their own html structure (<html>, <head>, <body> tags).
If you include a file, it will be placed inside your Joomla content, which is already inside a full html structure.
So if you want to load in html files, make sure they only contain the text part (what is inside the <body>).
Otherwise you will either have to use iframes or use some more advanced php code to strip the html structure away.