php中getservbyport与getservbyname函数用法实例

2015-01-24信息快讯网

这篇文章主要介绍了php中getservbyport与getservbyname函数用法,以实例形式分析了getservbyport与getservbyname函数获取server端的端口等信息的方法,需要的朋友可以参考下

本文实例讲述了php中getservbyport与getservbyname函数用法。分享给大家供大家参考。具体如下:

string getservbyport ( int $port , string $protocol ) 
 
*/ 
$services=array('80','21','22','23','25','143');      //定义数组 
foreach($services as $service)         //循环读取内容 
{ 
  $protocol=getservbyport($service,'tcp');       //返回端口号对应的协议 
  echo $service.":".$protocol."<br/>n";       //输出结果 
} 
 
/* 
int getservbyname ( string $service , string $protocol ) 
*/ 
 
$services=array('http','ftp','ssh','telnet','imap', 
'smtp','nicname','gopher','finger','pop3','www');       //定义一个数组 
foreach($services as $service)          //循环读取内容 
{ 
  $port=getservbyname($service,'tcp');        //获取数组元素对应端口 
  echo $service.":".$port."<br/>n";         //输出结果 
}

希望本文所述对大家的php程序设计有所帮助。

ucenter通信原理分析
php计划任务之ignore_user_abort函数实现方法
WampServer下安装多个版本的PHP、mysql、apache图文教程
PHP PDO fetch 模式各种参数的输出结果一览
PHP和Shell实现检查SAMBA与NFS Server是否存在
phpQuery让php处理html代码像jQuery一样方便
php中Socket创建与监听实现方法
php中socket通信机制实例详解
php使用sql server验证连接数据库的方法
php使用pdo连接mssql server数据库实例
php进行支付宝开发中return_url和notify_url的区别分析
腾讯微博提示missing parameter errorcode 102 错误的解决方法
PHP中使用file_get_contents抓取网页中文乱码问题解决方法
php中get_meta_tags()、CURL与user-agent用法分析
yii中widget的用法
Yii使用ajax验证显示错误messagebox的解决方法
Yii核心组件AssetManager原理分析
php中time()与$_SERVER[REQUEST_TIME]用法区别
php中获取主机名、协议及IP地址的方法
php单态设计模式(单例模式)实例
php中current、next与reset函数用法实例
php中filter_input函数用法分析
getimagesize获取图片尺寸实例
php使用fsockopen函数发送post,get请求获取网页内容的方法
PHP采用get获取url汉字出现乱码的解决方法
php 使用file_get_contents读取大文件的方法
php5.3提示Function ereg() is deprecated Error问题解决方法
PHP利用func_get_args和func_num_args函数实现函数重载实例
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2611816 bytes)
php实现把url转换迅雷thunder资源下载地址的方法
php几个预定义变量$_SERVER用法小结
php实现webservice实例
如何让CI框架支持service层
PHP连接sql server 2005环境配置及问题解决
Win2003+apache+PHP+SqlServer2008 配置生产环境
©2014-2024 dbsqp.com