0

我很好奇将这个 http://api.hostip.info/country.php?ip=141.100.10.49 (Result = DE) 的结果放入我可以用来写入我的数据库的变量中(最后一件事很容易我,但我很想知道如何做第一件事。在我脑海中的片段下面:-)

    <?php
    $in = HTTP_GET_RESPONSE('http://api.hostip.info/country.php?ip=141.100.10.49');
    echo $in;
    /*write to DB*/
    ?>

我在这里先向您的帮助表示感谢!

PS:我对java/python/C(+/++/#)了解不多

PPS: http: //kater.selfhost.me/stats/test.php这就是结果:-(

4

2 回答 2

0

它被称为file_get_contents

$in = file_get_contents('http://api.hostip.info/country.php?ip=141.100.10.49');

一般来说,PHP 中大多数与文件相关的函数都允许您提供 URL,并且它们会将远程文档视为文件(除非在您的php.ini.

于 2013-07-20T22:22:36.577 回答
0

如果您的系统配置正确,您可以使用:

 <?php
$in = file_get_contents('http://api.hostip.info/country.php?ip=141.100.10.49');
echo $in;
/*write to DB*/
?>

只需确保您已allow_url_fopen在 php.ini 中设置

于 2013-07-20T22:23:33.040 回答