Page 1 of 1

include variable & text

Posted: Fri Jul 16, 2010 12:27 pm
by tommyinnn
Hi everyone, I'm trying to create a include line using a variable and path
- this is to display my header

something like


<?php
$site = domain.com
include $site "." "/heading.php";
?>

so it would end up being
<?php include 'http://domain.com/heading.php'; ?>

thanks for any help any1 can give

Re: include variable & text

Posted: Sat Jul 17, 2010 4:01 pm
by JakeJ
Assuming you're trying to access content from the same site, try this instead:

Code: Select all

include('./directory/heading.php');
However if you have to do this many times with many sites, consider a function:

Code: Select all

function full_url($domain, $path, $filename) {
   $url = $domain.$path.$filename;
   return $url;
}
$full_url = function($domain, $path,$filename);
include($full_url);
I'm not entirely sure what you're trying to accomplish though, please clarify.