请帮助我,我不知道该怎么办。尝试过urlencode
,但不起作用
UTF-8不起作用。我需要脚本可以读取显示图像的撇号,但无事可做我不是程序员,现在需要您的帮助来解决此问题。
<?php
$cover_d = 'http://metalrockpopradio.caramania.com/blackblack.gif';
$sc_url_ip = "69.175.13.131";
$sc_url_port = "8050";
function getNowPlaying($sc_url_ip,$sc_url_port) {
$open = fsockopen($sc_url_ip,$sc_url_port,$errno,$errstr,'.5');
if ($open) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
stream_set_timeout($open,'1');
$read = fread($open,200);
$text = explode(",",$read);
if($text[6] == '' || $text[6] == '</body></html>') {
$msg = ' live stream ';
} else {
$msg = $text[6];
}
$text = $msg;
} else {
return false;
}
fclose($open);
return $text;
}
$current_song = getNowPlaying($sc_url_ip,$sc_url_port);
$current_song = iconv('ISO-8859-1', 'UTF-8', $current_song);
$singinfo = explode(" - ",$current_song);
$artist = urlencode($singinfo[0]);
$titel = urlencode(strip_tags($singinfo[1]));
$imgurl = @file_get_contents("http://api.depubliekeomroep.nl /anp/albumart.php?artiest=".$artist."&titel=".$titel."&size=extralarge");
if ($imgurl != "") {
print "<img src=\"" . $imgurl . "\">";
} else {
print "<img src=\"" . $cover_d . "\">";
}
?>
答案 0 :(得分:-1)
我们在谈论ASCII 39是吗?我的意思是这甚至有效...
<?php
$artist = "Tom Petty";
$title = "I won't back down";
$uri = "http://api.depubliekeomroep.nl/anp/albumart.php?artiest={$artist}&titel={$title}&size=extralarge";
var_dump(file_get_contents($uri));
'https://lastfm-img2.akamaized.net/i/u/300x300/05600d9c77a9288add89fac53d3482e7.png' (长度= 82)
也许提供一个实际的字符串示例给您带来麻烦?
虽然上面的方法对我有用,但可能取决于底层包装器。
最佳做法是:
$title = urlencode("I won't back down");