Edit report at https://bugs.php.net/bug.php?id=63730&edit=1
ID: 63730 User updated by: cojabo-php at cjbn dot net Reported by: cojabo-php at cjbn dot net Summary: gethostbyname() fails silently Status: Not a bug Type: Bug Package: Network related Operating System: Ubuntu LTS PHP Version: 5.3.19 Block user comment: N Private report: N New Comment: What is the reason for that failure? How do I determine this? It seems strange that the "intended behavior" would be to fail without giving the user any means whatsoever to correct the failure. Previous Comments: ------------------------------------------------------------------------ [2012-12-09 13:14:16] larue...@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php "Returns the IPv4 address or a string containing the *unmodified hostname* on failure." http://us1.php.net/manual/en/function.gethostbyname.php ------------------------------------------------------------------------ [2012-12-08 23:18:07] cojabo-php at cjbn dot net Description: ------------ gethostbyname() fails to return an IP; dns_get_record() works. No error message of any kind is generated. This happens for any domain I've tried. Test script: --------------- <pre> <? $domain='www.example.com'; echo "gethostbyname($domain)\n"; var_dump(gethostbyname($domain)); echo "\n"; echo "dns_get_record($domain,DNS_A)\n"; var_dump(dns_get_record($domain,DNS_A)); echo $notice; fopen('warning','r'); Expected result: ---------------- gethostbyname(www.example.com) string() "192.0.43.10" dns_get_record(www.example.com,DNS_A) array(1) { [0]=> array(5) { ["host"]=> string(15) "www.example.com" ["type"]=> string(1) "A" ["ip"]=> string(11) "192.0.43.10" ["class"]=> string(2) "IN" ["ttl"]=> int(3020) } } Notice: Undefined variable: notice in /www/dev/dynamic/test.php on line 14 Warning: fopen(warning): failed to open stream: No such file or directory in /www/dev/dynamic/test.php on line 15 Actual result: -------------- gethostbyname(www.example.com) string(15) "www.example.com" dns_get_record(www.example.com,DNS_A) array(1) { [0]=> array(5) { ["host"]=> string(15) "www.example.com" ["type"]=> string(1) "A" ["ip"]=> string(11) "192.0.43.10" ["class"]=> string(2) "IN" ["ttl"]=> int(3020) } } Notice: Undefined variable: notice in /www/dev/dynamic/test.php on line 14 Warning: fopen(warning): failed to open stream: No such file or directory in /www/dev/dynamic/test.php on line 15 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63730&edit=1