Get the IPv4 address corresponding to a given Internet host name in PHP

Description

The following code shows how to get the IPv4 address corresponding to a given Internet host name.

Example


// w  w  w . ja v  a  2 s.  c  o m
//gethostbyname() example
<?php
$ip = gethostbyname('www.example.com');
echo $ip;
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Development »




Environment
Error
Hash
Include
Locale
Math
Network
Output
Reflection
PHP Regular Expressions