php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60824 gethostbyaddr() returns FALSE on failure
Submitted: 2012-01-20 20:07 UTC Modified: 2012-01-21 20:52 UTC
From: alvaro at demogracia dot com Assigned: frozenfire (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.9 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alvaro at demogracia dot com
New email:
PHP Version: OS:

 

 [2012-01-20 20:07 UTC] alvaro at demogracia dot com
Description:
------------
---
From manual page: http://www.php.net/function.gethostbyaddr
---

In "Return Values" we read:

«Returns the host name or the unmodified ip_address on failure.»
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

However, there are situations where the function appears to return FALSE on failure.

Test script:
---------------
<?php

// Return unmodified argument
var_dump( gethostbyaddr(33) );
var_dump( gethostbyaddr('192.168.0.100') ); // Non-existing LAN address

// Return FALSE and trigger a warning
var_dump( gethostbyaddr(NULL) );
var_dump( gethostbyaddr('php.net') );



Expected result:
----------------
string(2) "33"
string(13) "192.168.0.100"
string(0): ""
string(7): "php.net"

Actual result:
--------------
string(2) "33"
string(13) "192.168.0.100"

Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\tmp\test.php on line 8
bool(false)

Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\tmp\test.php on line 9
bool(false)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-21 20:39 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=322545
Log: Clarified that gethostbyaddr will return false on malformed input. Closes bug #60824.
 [2012-01-21 20:52 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 [2012-01-21 20:52 UTC] frozenfire@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.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 09:00:02 2026 UTC