1. string getservbyport ( int $port , string $protocol ) 
  2.  
  3. */ 
  4. $services=array('80','21','22','23','25','143');      //定義數(shù)組 
  5. foreach($services as $service)         //循環(huán)讀取內(nèi)容 
  6.   $protocol=getservbyport($service,'tcp');       //返回端口號對應(yīng)的協(xié)議 
  7.   echo $service.":".$protocol."<br/>n";       //輸出結(jié)果 
  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');       //定義一個數(shù)組 
  15. foreach($services as $service)          //循環(huán)讀取內(nèi)容 
  16.   $port=getservbyname($service,'tcp');        //獲取數(shù)組元素對應(yīng)端口 
  17.   echo $service.":".$port."<br/>n";         //輸出結(jié)果 
  18.   //開源代碼phpfensi.com 
  19. }
轉(zhuǎn)載請注明來源:php中 getservbyport getservbyname函數(shù)實例

  哈爾濱品用軟件有限公司致力于為哈爾濱的中小企業(yè)制作大氣、美觀的優(yōu)秀網(wǎng)站,并且能夠搭建符合百度排名規(guī)范的網(wǎng)站基底,使您的網(wǎng)站無需額外費用,即可穩(wěn)步提升排名至首頁。歡迎體驗最佳的哈爾濱網(wǎng)站建設(shè)