时间: 2020-10-12|tag:35次围观|0 条评论

php中 getservbyport getservbyname函数实例

  1. string getservbyport ( int $port , string $protocol ) 
  2.  
  3. */ 
  4. $services=array('80','21','22','23','25','143');      //定义数组 
  5. foreach($services as $service)         //循环读取内容 
  6.   $protocol=getservbyport($service,'tcp');       //返回端口号对应的协议 
  7.   echo $service.":".$protocol."<br/>n";       //输出结果 
  8.  
  9. /* 
  10. int getservbyname ( string $service , string $protocol ) 
  11. */ 
  12.  
  13. $services=array('http','ftp','ssh','telnet','imap'
  14. 'smtp','nicname','gopher','finger','pop3','www');       //定义一个数组 
  15. foreach($services as $service)          //循环读取内容 
  16.   $port=getservbyname($service,'tcp');        //获取数组元素对应端口 
  17.   echo $service.":".$port."<br/>n";         //输出结果 
  18.   //开源代码phpfensi.com 
  19. }

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《php中 getservbyport getservbyname函数实例 – php函数
   

还没有人抢沙发呢~