getservbyname php,php中getservbyport与getservbyname函数用法实例
本文實(shí)例講述了php中g(shù)etservbyport與getservbyname函數(shù)用法。分享給大家供大家參考。具體如下:
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');?????? //返回端口號對應(yīng)的協(xié)議
echo $service.":".$protocol."
n";?????? //輸出結(jié)果
}
/*
int getservbyname ( string $service , string $protocol )
*/
$services=array('http','ftp','ssh','telnet','imap',
'smtp','nicname','gopher','finger','pop3','www');?????? //定義一個數(shù)組
foreach($services as $service)????????? //循環(huán)讀取內(nèi)容
{
$port=getservbyname($service,'tcp');??????? //獲取數(shù)組元素對應(yīng)端口
echo $service.":".$port."
n";???????? //輸出結(jié)果
}
希望本文所述對大家的php程序設(shè)計有所幫助。
總結(jié)
以上是生活随笔為你收集整理的getservbyname php,php中getservbyport与getservbyname函数用法实例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java json设置编码,如何设置数组
- 下一篇: 日利率怎么算