欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php中g(shù)etservbyport與getservbyname函數(shù)用法實(shí)例

 更新時(shí)間:2014年11月18日 14:31:01   投稿:shichen2014  
這篇文章主要介紹了php中g(shù)etservbyport與getservbyname函數(shù)用法,以實(shí)例形式分析了getservbyport與getservbyname函數(shù)獲取server端的端口等信息的方法,需要的朋友可以參考下

本文實(shí)例講述了php中g(shù)etservbyport與getservbyname函數(shù)用法。分享給大家供大家參考。具體如下:

復(fù)制代碼 代碼如下:

string getservbyport ( int $port , string $protocol )
 
*/
$services=array('80','21','22','23','25','143');      //定義數(shù)組
foreach($services as $service)         //循環(huán)讀取內(nèi)容
{
  $protocol=getservbyport($service,'tcp');       //返回端口號(hào)對(duì)應(yīng)的協(xié)議
  echo $service.":".$protocol."<br/>n";       //輸出結(jié)果
}
 
/*
int getservbyname ( string $service , string $protocol )
*/
 
$services=array('http','ftp','ssh','telnet','imap',
'smtp','nicname','gopher','finger','pop3','www');       //定義一個(gè)數(shù)組
foreach($services as $service)          //循環(huán)讀取內(nèi)容
{
  $port=getservbyname($service,'tcp');        //獲取數(shù)組元素對(duì)應(yīng)端口
  echo $service.":".$port."<br/>n";         //輸出結(jié)果
}

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論