-3

I need to get the IP address of a domain by the domain name.

  1. Site: hotmail.com / 65.55.72.151
  2. Site: domain.com / 65.254.244.180

Can it be done, and in that case, how can I do it?

Nicholas Carey
  • 71,308
  • 16
  • 93
  • 135
Hadidi44
  • 1,007
  • 2
  • 9
  • 7

1 Answers1

9

You can use this code:

<?php
$ip = gethostbyname('www.site.com');

echo $ip;
?>

Or, you could operate it dynamically...

<?php
$url = $_GET['url'];
$ip = gethostbyname($url);

echo $ip;
?>
Mattios550
  • 372
  • 1
  • 5
  • 18