tags:

views:

43

answers:

2

I'm trying to make a request to a website this way :

file_get_contents('http://www.yahoo.com/index.php?var=value');

in the index.php file ( Receiver ) , when I try to echo $_GET['var'] from within the index.php and get the response with file_Get_contents, I get nothing. curl is getting it right , but I just want to know it this way in case curl is not installed

sender:

echo file_get_contents('http://www.yahoo.com/index.php?var=value');

receiver : index.php contains

<?php
echo $_GET['var'];
?>
A: 

file_get_contents returns the content of the file.

$var = file_get_contents('http://www.yahoo.com/index.php?var=value');

The function returns the read data or FALSE on failure. http://php.net

galambalazs
Ofcourse I did that ,I'm trying to simplify it
Naughty.Coder
Alright you may confuse some things. Now i see you said receiver side, but the you say curl is getting it right. What curl would do on the receiver side? I don't get what you are after.
galambalazs
i've edited the question , please read it again to understand me better
Naughty.Coder
is `allow_url_fopen = On` in your configuration? **Also, are you trying to fetch a local file or one with an url?**
galambalazs
i've just tested it right now and it works perfectly on my localhost.
galambalazs
it just returns true instead of the var query string , damn! what is wrong .. I'm fetching an online website
Naughty.Coder
ohhhh , i'm an asshole ... sorry guys .. I figured that out
Naughty.Coder
I'm glad, lol :)))
galambalazs
thank you galambalazs
Naughty.Coder
+1  A: 

Try something like this in your receiver...

$uri = parse_url($_SERVER['REQUEST_URI']);
echo $uri["query"];
motionman95