#vars.php

<?php // begin with a PHP open tag.
$fruit = 'apple';
echo "I was imported";
return 'Anything you like.';
?>

#test.php

<?php
include 'vars.php';
echo $fruit . "\n";   # => apple
/\* Same as include,
cause an error if cannot be included\*/
require 'vars.php';
// Also works
include('vars.php');
require('vars.php');
// Include through HTTP
include 'http://x.com/file.php';
// Include and the return statement
$result = include 'vars.php';
echo $result;  # => Anything you like.
?>
Comments