Thursday, April 18, 2013

Check Internet Connection is On or Off using Php

Hello Friends,
Today we learn About how to Check Internet Connection is On or Off using Php script is very interesting.Lets see the php magic.

Check Internet is On or Off Using Php

Here we can use fsockopen php function.
in this function contain below parameter.
1)hostname : provide the hostname like :www.google.com
2)port     : add port number like : 80
3)errno    : error number generate by itself.
4)errstr   : display error message when connection fail.
5)timeout  : The connection timeout, in seconds.
example :
if(!$sock= @fsockopen('www.google.com',80,$num,$error,5))
echo "Off line";
else
echo "ok";

No comments:

Post a Comment

Thanks....