php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #48008 gethostbyname does not return IPv6 addresses
Submitted: 2009-04-17 21:10 UTC Modified: 2009-04-21 00:53 UTC
From: carsten_sttgt at gmx dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.9 OS: Windows_NT
Private report: No CVE-ID: None
 [2009-04-17 21:10 UTC] carsten_sttgt at gmx dot de
Description:
------------
Hello,

I have a system e.g.:
hostname: localhost
ip1: ::1
ip2: 127.0.0.1

(the problem is not specific to localhost)

A fopen('http://localhost/', 'rb'); connect correctly to "::1".

But gethostbyname('localhost'); returns "127.0.0.1".
gethostbynamel('localhost'); also returns only a array with "127.0.0.1".

Well, how can I know which IP PHP is using in a e.g. fopen() call?

And if gethostbyname() can't work with IPv6, this should be noted in the PHP manual. From what I can see, gethostbyaddr() is also working only with IPv4 (don't see this in the manual).

In phpinfo() i can read:
| IPv6 Support 	enabled 

Regards,
Carsten



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-20 09:30 UTC] jani@php.net
See also bug #33170
 [2009-04-21 00:53 UTC] joey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

gethostbyname and gethostbynamel are now documented as giving the "IPv4
address"
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 25 07:00:02 2025 UTC