file_get_Contents won't send query strings in url , thus receiving nothing with $_GET
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 j开发者_StackOverflow中文版ust 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'];
?>
Try something like this in your receiver...
$uri = parse_url($_SERVER['REQUEST_URI']);
echo $uri["query"];
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
精彩评论