d-_*_*_-b 6 php spaces file-get-contents
我有一个问题,即使我将空格替换为%20并将此内容作为终极URL,浏览器将"%20"变为"%2520"
这是我的代码,任何建议让这个工作?这似乎很容易,但我卡住了:/
<?php
//$_GET['song'] will contain a song name with spaces
$song = str_replace(array("%20", "&", "?" , "/"), array(" ", "", "", ""), $_GET['song']);
// I use this to check how the GET 'song' looks after the str_replace
$list = "http://www.lyrdb.com/lookup.php?q=" . $song . "&for=fullt";
echo "list url is " . $list . "<hr>";
$content = file_get_contents("http://www.lyrdb.com/lookup.php?q=" . str_replace(" ", "%20", $song) . "&for=fullt");
echo $content;
?>
Run Code Online (Sandbox Code Playgroud)
如果你去http://webservices.lyrdb.com/lookup.php?q=red%20hot%20chili%20peppers&for=fullt结果应该输出一个歌词代码列表.
当我去我的网站/?song =红辣椒时,它也将空格转换为%20,但如果看起来浏览器将%'转换为%25.
有人可以帮我吗?
Che*_*ery 14
$song = $_GET['song']);
$url = "http://www.lyrdb.com/lookup.php?for=fullt&q=";
echo "list url is " . htmlentities($url . $song) . "<hr>";
$content = file_get_contents($url . urlencode($song));
echo $content;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12894 次 |
| 最近记录: |