轉(zhuǎn)載請注明來源:php中 getservbyport 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."<br/>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."<br/>n"; //輸出結(jié)果
- //開源代碼phpfensi.com
- }
哈爾濱品用軟件有限公司致力于為哈爾濱的中小企業(yè)制作大氣、美觀的優(yōu)秀網(wǎng)站,并且能夠搭建符合百度排名規(guī)范的網(wǎng)站基底,使您的網(wǎng)站無需額外費用,即可穩(wěn)步提升排名至首頁。歡迎體驗最佳的哈爾濱網(wǎng)站建設(shè)。
