Page 1 of 1

Reading remote text?

Posted: Wed Oct 18, 2006 1:12 pm
by robvan
Hello,

I'm having a php issue that I imagine would be very easy to solve if I knew what to be searching for, and provided it's possible, which it really seems like it should be. I am writing a script, and I want to be able to run a remote php script and use the result of that in this script. For instance, the script at http://www.mydomain.com/script.php?variable=3 will, when run in a browser, write out a string. I want to write a php script on another domain that, when run, will call the first script, get the string it writes out, and use it to do something else.
Any help on how to do this, or a term to describe it that I could be searching for would be most appreciated,

Thanks,
Rob

Posted: Wed Oct 18, 2006 1:19 pm
by akimm
##EDIT I may have misread the question, if so as feyd said, file_get_contents will dump the contents of one page, I thought you wanted to implement the script into your site.

PHP.net or google would do this trick.


the function(s) you're searching for vary on the exact purpose,

Code: Select all

<?php
include("http://www.phonybolognesite1.com/file.php");

require("http://www.phonybolognesite1.com/file.php");

include_once("http://www.phonybolognesite1.com/file.php");

require_once("http://www.phonybolognesite1.com/file.php");

?>
They all serve the same basic purpose, but there are nuances in their usage.

Posted: Wed Oct 18, 2006 1:21 pm
by feyd
file_get_contents() if the allow_url_fopen directive is enabled. If not, cURL or some relative (Snoopy, perhaps.)

Posted: Wed Oct 18, 2006 1:41 pm
by robvan
Thank you both, file_get_contents was what I was looking for