PHP 8.3.4 Released!

geoip_continent_code_by_name

(PECL geoip >= 1.0.3)

geoip_continent_code_by_name二文字の大陸コードを取得する

説明

geoip_continent_code_by_name(string $hostname): string

geoip_continent_code_by_name() 関数は、 ホスト名あるいは IP アドレスに対応する二文字の大陸コードを返します。

パラメータ

hostname

場所を探す対象となるホスト名あるいは IP アドレス。

戻り値

成功した場合には二文字の大陸コード、 アドレスがデータベースで見つからない場合には false を返します。

大陸コード
コード 大陸名
AF アフリカ
AN 南極
AS アジア
EU ヨーロッパ
NA 北アメリカ
OC オセアニア
SA 南アメリカ

例1 geoip_continent_code_by_name() の例

これは、ホスト example.com がどこにあるのかを表示します。

<?php
$continent
= geoip_continent_code_by_name('www.example.com');
if (
$continent) {
echo
'This host is located in: ' . $continent;
}
?>

上の例の出力は以下となります。

This host is located in: NA

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top