0
を推測:json_decodeリターンヌル私は自分のサーバー上でこれを実行しよう
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
echo $ip;
$city = $details -> city;
echo $city;
?>
しかし、この印刷IPのみ。 サーバーの問題または構成ですか?
file_get_contents( "http://ipinfo.io/{$ip}/json")の内容は何ですか? –
'var_dump($ details);'は何を表示しますか? – Barmar
あなたのコードはうまく動作します。サーバー上で 'url_fopen'を有効にしていない可能性がありますか? 'error_reporting(E_ALL);でエラー報告を有効にする – Barmar