Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

gethostbyname(3) [php man page]

GETHOSTBYNAME(3)							 1							  GETHOSTBYNAME(3)

gethostbyname - Get the IPv4 address corresponding to a given Internet host name

SYNOPSIS
string gethostbyname (string $hostname) DESCRIPTION
Returns the IPv4 address of the Internet host specified by $hostname. PARAMETERS
o $hostname - The host name. RETURN VALUES
Returns the IPv4 address or a string containing the unmodified $hostname on failure. EXAMPLES
Example #1 A simple gethostbyname(3) example <?php $ip = gethostbyname('www.example.com'); echo $ip; ?> SEE ALSO
gethostbyaddr(3), gethostbynamel(3), inet_pton(3), inet_ntop(3). PHP Documentation Group GETHOSTBYNAME(3)

Check Out this Related Man Page

INET_PTON(3)								 1							      INET_PTON(3)

inet_pton - Converts a human readable IP address to its packed in_addr representation

SYNOPSIS
string inet_pton (string $address) DESCRIPTION
This function converts a human readable IPv4 or IPv6 address (if PHP was built with IPv6 support enabled) into an address family appropri- ate 32bit or 128bit binary structure. PARAMETERS
o $address - A human readable IPv4 or IPv6 address. RETURN VALUES
Returns the in_addr representation of the given $address, or FALSE if a syntactically invalid $address is given (for example, an IPv4 address without dots or an IPv6 address without colons). EXAMPLES
Example #1 inet_pton(3) Example <?php $in_addr = inet_pton('127.0.0.1'); $in6_addr = inet_pton('::1'); ?> CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | This function is now available on Windows plat- | | | forms. | | | | +--------+---------------------------------------------------+ SEE ALSO
ip2long(3), long2ip(3), inet_ntop(3). PHP Documentation Group INET_PTON(3)
Man Page

5 More Discussions You Might Find Interesting

1. Programming

regarding gethostbyname()

iam using gethostbyname for verifing whether net is active or not it's work fine but how it's work i mean whether it is using ping or sending socket, who it determining the internet . thank u in advance sree (2 Replies)
Discussion started by: phani_sree
2 Replies

2. IP Networking

gethostbyname_r returns NULL when hostname has dash

We have a code to find the DNS entry of a host that has a trailing '-' in its url (format example: mysite-.watch.com): if(gethostbyname_r(host,host_ent,host_buffer,host_buffer_size,&host_error)==NULL) { //failed } But when remove the '-' from the host name the code does not return... (12 Replies)
Discussion started by: uunniixx
12 Replies

3. Programming

gethostname warning

Hi, does anyone knows how to get rid of this annoying warning? Thank you! #include <netdb.h> main() { gethostbyname("test"); } $ gcc -static test.c /tmp/ccW9HG18.o: In function `main': test.c:(.text+0x19): warning: Using 'gethostbyname' in statically linked applications requires at... (3 Replies)
Discussion started by: paulquater
3 Replies

4. Windows & DOS: Issues & Discussions

gethostbyname failed

gethostbyname is failing and returning NULL on Windows 7. Should i use inet_addr or there is other way to get it (3 Replies)
Discussion started by: Saurabh78
3 Replies

5. IP Networking

The system function gethostbyname() failed to find the client's host name

As we are facing issue with this server connection. The error is: The system function gethostbyname() failed to find the client's host name. how can i check if the server "server1" is able to resolve the client hostname (hosts / dns)? i can ping the client from server. any... (1 Reply)
Discussion started by: jinslick25
1 Replies