2016-06-30 8 views

答えて

0
$host = 'stackoverflow.com'; 
$ports = array(21, 25, 80, 81, 110, 443, 3306); 

foreach ($ports as $port) 
{ 
    $connection = @fsockopen($host, $port); 

    if (is_resource($connection)) 
    { 
     echo '<h2>' . $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') is open.</h2>' . "\n"; 

     fclose($connection); 
    } 

    else 
    { 
     echo '<h2>' . $host . ':' . $port . ' is not responding.</h2>' . "\n"; 
    } 
} 

アウトはこの

stackoverflow.com:21 is not responding. 
stackoverflow.com:25 is not responding. 
stackoverflow.com:80 (http) is open. 
stackoverflow.com:81 is not responding. 
stackoverflow.com:110 is not responding. 
stackoverflow.com:443 is not responding. 
stackoverflow.com:3306 is not responding. 
+0

のような返事に感謝を見て置くが、このコードは正しい結果を与えていません – baljeet

関連する問題