如何將查詢字符串名稱放在php中?在php代碼中查詢字符串[已解決]
$file_get_html('http://localhost/search/?q=');
當訪問本地主機/ ?name=example
的代碼看起來像這樣
$file_get_html('http://localhost/search/?q=example');
我不知道如何把$_GET['url']
一個PHP :(
如何將查詢字符串名稱放在php中?在php代碼中查詢字符串[已解決]
$file_get_html('http://localhost/search/?q=');
當訪問本地主機/ ?name=example
的代碼看起來像這樣
$file_get_html('http://localhost/search/?q=example');
我不知道如何把$_GET['url']
一個PHP :(
的問題不是很清楚裏面,但我懷疑這就是答案:
file_get_html('http://localhost/search/?q=' . urlencode($_GET['url']));
注意:未定義變量:file_get_html在C:\ _服務器\ htdocs中上線\ test.php的7 致命錯誤:函數名必須在C的字符串:\ _服務器\ htdocs中\ test.php的第7行 線7 :'$ html = $ file_get_html('http:// localhost/bsearch /?q ='。urlencode($ _ GET ['movie']));' – Theus
你沒有看到我在一小時前寫過的評論嗎? 'file_get_html()'之前不應該有'$'。 – Barmar
瞭解代碼:http://tny.cz/b58d4b02 – Theus
的q =例子會讓喲你使用類似$ example = $ _GET ['q'], 和$ example應該等於查詢字符串中q的值。
如果你有一個查詢字符串,看起來像這樣:
?q=example&url=myurl.com
您可以訪問這樣的q和URL參數:
$q = $_GET['q']; // which will equal 'example'
$url = $_GET['url']; // which will equal 'myurl.com'
如果這是你正在嘗試做的。
但是如何放入'$ file_get_html'? – Theus
$url = urlencode($_GET['url']);
$contents = file_get_contents("http://localhost/search/?q={$url}");
var_dump($contents);
file_get_html($ _ GET ['url']); - 如果這真的是你的意思。 – 2013-06-20 00:32:26
'file_get_html'之前沒有'$' – Barmar
問題不是很清楚。您是否試圖將您收到的查詢字符串與其他網址合併? – Barmar