Example 1 — Resolve a Host to One IPv4 Address
Look up example.com and print the address. The IP below is a typical sample.
<?php
$host = "example.com";
$ip = gethostbyname($host);
echo $ip; How It Works
- Store the host name in $host.
- gethostbyname() asks DNS for one IPv4 address.
- Echo prints the address string.
- 93. 184.216.34 is a well-known sample for example.com.

