|
Posted by Oli Filth on 01/10/06 18:57
Justin Koivisto said the following on 10/01/2006 14:57:
> Oli Filth wrote:
>
>>* If it is, then script.php is being run on the remote server, not the
>>local server, so you're actually include()-ing the *output* of
>>script.php, not the PHP code itself. In which case, you will need to
>>either pass the hostname in the request for script.php, e.g.:
>>
>>include("http://remote.server.example.com/script.php?host=http://local.example.com/mainscript.php");
>
> Out of curiosity, does the $_GET array actually get populated with
> values sent in this way for the remote script?
Yes. The receiving remote server doesn't care (or know) where the HTTP
request for script.php came from, so it acts exactly as if someone had
requested that URL from their browser.
> I know that if you do something like:
> include 'myfile.php?var=val1';
>
> That php looks for a file with that exact name (which will not exist in
> most cases). Therefore in order to make that work (locally anyway),
> you'd need to set the variable before the file was included.
Well yes, because "?var=var1" is meaningless in a local filesystem.
Setting the local variable works because both scripts are being run
locally in the same PHP instance.
If you do something like include("http://example.com/file.php?foo=bar"),
then PHP goes away and performs an HTTP request, where "?foo=bar" has
meaning, i.e. a GET sub-string.
--
Oli
[Back to original message]
|