Forum Moderators: coopster

Message Too Old, No Replies

Making variables available to included files

         

trevordixon

3:36 am on Jan 20, 2006 (gmt 0)

10+ Year Member




<?php
$domain = $_SERVER['HTTP_HOST'];
$filename = $_GET['filename'];
$pageid = $_GET['pageid'];
include "http://www.adifferentdomain.com/webfiles/" . $filename . ".php";
?>

Is it possible for the variables defined above to be made available to the included file? It seems to me that the PHP file is being executed without "looking at" the variables.

Thank you,
Trevor

coopster

2:50 pm on Jan 20, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes it will but not when you include the file through the HTTP protocol like that. If the file is on your site you include it from the filesystem then PHP will add it to your existing script at that point and parse it just as if it were written right into your existing script.
include [php.net] 'myfile.php';

trevordixon

3:14 pm on Jan 21, 2006 (gmt 0)

10+ Year Member



Oh I just realized that both sites will be on the same server, so I can just include it through the filesystem. Thanks for your help.