From: webdev at concraption dot com Operating system: Windows 2000/XP PHP version: 5.0.5 PHP Bug Type: *Network Functions Bug description: gethostbynamel() returns wrong type
Description: ------------ The online documentation for gethostbynamel() states that if the lookup fails, it will return FALSE. The Win32 binary of PHP 5.0.5 returns what appears to be an empty string, rather than FALSE on the case of failed lookup. If this is an error in the documentation, I apologize for your time. I was able to devise a workaround using is_array() in an IF block, but out of curiousity I added die(">".$hosts."<"); and PHP returned ><, which leads me to believe that when the lookup fails, $hosts is an empty string rather than FALSE. Reproduce code: --------------- <? $hosts = gethostbynamel($hostname); if ($hosts != FALSE) { echo $hostname." is tied to the following IPs:<br><br>"; foreach ($hosts as $ip) { echo "IP: ".$ip."<br>"; } } else { echo $hostname." is not tied to any IP."; } Expected result: ---------------- $hostname is tied to the following IPs: IP: first_ip IP: second_ip etc... OR $hostname is not tied to any IP. Actual result: -------------- Warning: Invalid argument supplied for foreach() in C:\Server\sites\apps\iptools.php on line 12 -- Edit bug report at http://bugs.php.net/?id=34553&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34553&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34553&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34553&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34553&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34553&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34553&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34553&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34553&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34553&r=support Expected behavior: http://bugs.php.net/fix.php?id=34553&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34553&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34553&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34553&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34553&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34553&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34553&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34553&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34553&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34553&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34553&r=mysqlcfg