PHP gethostbyname() Function

❮ PHP Network Reference

Example

A gethostbyname() example:

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


Definition and Usage

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

Syntax

gethostbyname(hostname)

Parameter Values

Parameter Description
hostname Required. Specifies a hostname (like "www.w3schools.com")

Technical Details

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

❮ PHP Network Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.