You are here: Re: How to get url of current url from included script on different server « PHP Programming Language « IT news, forums, messages
Re: How to get url of current url from included script on different server

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация