ID: 34553 Updated by: [EMAIL PROTECTED] Reported By: webdev at concraption dot com -Status: Open +Status: Feedback Bug Type: *Network Functions Operating System: Windows 2000/XP PHP Version: 5.0.5 New Comment:
Your code doesn't really depend on what the return value is, as ("" == false) in PHP. So if you get the error you get, $hosts is neither empty string, nor false. And I can't reproduce it, btw. So please come up with the real code. Previous Comments: ------------------------------------------------------------------------ [2005-09-19 22:03:14] webdev at concraption dot com string(0) "" ------------------------------------------------------------------------ [2005-09-19 21:44:02] [EMAIL PROTECTED] what do you get with this: <?php ... var_dump(gethostbynamel($hostname)); ... ?> ? ------------------------------------------------------------------------ [2005-09-19 21:39:58] webdev at concraption dot com 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 this bug report at http://bugs.php.net/?id=34553&edit=1