【发布时间】:2015-04-10 20:07:22
【问题描述】:
我想兑换货币,我正在使用下面的函数
function convertCurrency($amount, $from, $to){
$url = "https://www.google.com/finance/converter?a=$amount&from=$from&to=$to&meta=ei";
$data = file_get_contents($url);
preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);
$converted = preg_replace("/[^0-9.]/", "", $converted[1]);
return round($converted, 3);
}
但是这个功能对我不起作用并给出以下错误:
警告:file_get_contents(https://www.google.com/finance/converter?a=350&from=USD&to=YEN&meta=ei) [function.file-get-contents]:无法打开流:在第 6 行的 /home/hydra/public_html/recentportfolio/bookitla2/index.php 中找不到合适的包装器
请给我一个快速的解决方案。
【问题讨论】:
-
同样的代码在 localhost 上运行完美,但在服务器上不运行