gethostbyname() Function PHP

The gethostbyname() function returns the IPv4 address for a given domain/host name.

Syntax

gethostbyname(hostname)

Parameter

ParameterDescription
hostnameRequired. Specifies a hostname (like "www.codesprogram.com")

Technical Details

Return Value:The IPv4 address on success. The hostname on failure.
PHP Version:4.0+

Example

<?php
$ip = gethostbyname("www.codesprogram.com");
echo $ip;
?>

kabeer

Added  09 Dec 2022, 11:03 am

Article tags

Php
×
SignUp with Email
X