Php 如何在URL中使用带有非ASCII字符的file_get_contents()?

Php 如何在URL中使用带有非ASCII字符的file_get_contents()?,php,html,encoding,Php,Html,Encoding,我试图从一个网站获取数据,并在我的PHP脚本中使用它 我试图找到的链接是: ★%20刺刀 这是我的密码: <?php $skin = $_GET['market_hash_name']; $link = "http://steamcommunity.com/market/priceoverview/?country=US&currency=3&appid=730&market_hash_name=".$skin.""; $FN = file_get_content

我试图从一个网站获取数据,并在我的PHP脚本中使用它

我试图找到的链接是: ★%20刺刀

这是我的密码:

<?php

$skin = $_GET['market_hash_name'];
$link = "http://steamcommunity.com/market/priceoverview/?country=US&currency=3&appid=730&market_hash_name=".$skin."";
$FN = file_get_contents($link);

echo $FN;
?>
function getPrice($string) {
$skin = urlencode($_GET['market_hash_name']);
$link = "http://steamcommunity.com/market/priceoverview/?country=US&currency=3&appid=730&market_hash_name=".$skin." ".$string;
$content = file_get_contents($link);
$data = json_decode($content, true);
return $data['lowest_price'];
}
$FN = getPrice("(Factory New)");
$MW = getPrice("(Minimal Wear)");
$FT = getPrice("(Field-Tested)");
$WW = getPrice("(Well-Worn)");
$BS = getPrice("(Battle-Scarred)");


echo "Factory New: $FN; Minimal Wear: $MW; Field-Tested: $FT; Well-Worn: $WW; Battle-Scared: $BS";

除其他字符外,查询字符串中必须包含非ASCII字符

$skin = url_encode($_GET['market_hash_name']);
$link = "http://steamcommunity.com/market/priceoverview/?country=US&currency=3&appid=730&market_hash_name=".$skin."";
$FN = file_get_contents($link);

http://steamcommunity.com/market/priceoverview/?country=US¤cy=3&appid=730&market_hash_name=%E2%98%85%20Bayonet
尝试设置unicode字符,而不是复制/粘贴此天气字符:★;根据您的编辑,您将需要使用Curl。是否要放置一个示例?请参阅堆栈上的此问答-您可以通过谷歌搜索“Curl网站php”来进一步研究。你会发现大量的结果,其中一些可能会引导你回到其他问答的堆栈。