2011-10-25 30 views
0

我确定这已经在堆栈中回答过,但我不知道用什么适当的术语来找到我想要的结果。来自url的PHP查询

我想要一个URL的值,并将其输入到我的PHP脚本。所以,如果我转到:

http://mydomain/search.php='MYSEARCHQUERY'

的search.php中会采取MYSEARCHQUERY作为值。

<?php 
$html=file_get_contents('http://anotherwebsite/MYSEARCHQUERY'); 
?> 

回答

3

的URL会是这样的:

http://mydomain/search.php?query=MYSEARCHQUERY 

和PHP:

$html = file_get_contents('http://anotherwebsite/' . $_GET['query']); 
+0

正要downvote,但您的编辑被迅速推到我的浏览器。 +1当之无愧 – Cyclone

+0

天才,谢谢! :) – Nick