刚才看了一下英文资料,关于fsockopen,后面可以接一个float timeout; int fsockopen ( string hostname, int port [, int errno [, string errstr [, float timeout]]]) if 条件改为 (@fsockopen("www.163.com",80, &$errno, &$errstr,1)||(@fsockopen("www.sohu.com",80, &$errno, &$errstr,1)) 呵呵,即最大允许timeout为1 second
传回机器名称。语法: string gethostbyaddr(string ip_address);传回值: 字串函式种类: 网路系统
内容说明
本函式可传回某个 IP 网址的机器名称 (Domain Name)。若执行失败,则传回原来的 IP 网址。
使用范例
下例的传回值为 dns.biglobe.net.tw<?
echo gethostbyaddr("202.166.255.97");
?>
int fsockopen(string hostname, int port, int [errno], string [errstr], int [timeout]);
这个函数
联一个网址,如www.163.com的http服务的80端口,
如
<?if (@fsockopen("www.163.com",80, &$errno, &$errstr))
echo "成功联上互联网";
else
echo ("无法联上互联网,出错原因:$errstr,代码:$errno");
?>
本方法成功通过编译
联不上www.163.com应该算联不上互联网了
如果觉得163不够的话,把if的条件改为
(@fsockopen("www.163.com",80, &$errno, &$errstr)||(@fsockopen("www.sohu.com",80, &$errno, &$errstr))
这样绝对保险
因为两个网站不可能同时出问题,如果两个都联不上,呵只能是你机器的原因了,
好像可以,但是当联不网时的判断太慢了,10分还没出来,等不急了,我又插上网线了,呵呵,:}
对不起,我再看看
int fsockopen ( string hostname, int port [, int errno [, string errstr [, float timeout]]])
if 条件改为
(@fsockopen("www.163.com",80, &$errno, &$errstr,1)||(@fsockopen("www.sohu.com",80, &$errno, &$errstr,1))
呵呵,即最大允许timeout为1 second
是用户吗?在每次断网前...让用户在地址栏里 输入:
http://xxx.xxx.xxx.xxx/offline.php
????不太可能吧。
清华大学出版社 英文(影印版)