Category Archives: PHP

Check server status with PHP

Hi, today I’m going to give you a little snippet on testing if a server with a specific port is online or not.First of all this is going to be a function with 2 parameters, server ip and port.We are going to test if the server is online or not with the fsockopen() function that will require you to have PHP Sockets activated on your host.

to  access the function you simple replace the $ip with the domain or the ip and the $port with the port you want to check.

and thats it, thanks for following me.

How to disable errors for FSOCKOPEN

Hi, today I want to share with you a little tip on the FSOCKOPEN function.You know that when fsockopen function fails on php it always gives you a warning like this:

Warning: fsockopen(): unable to connect to google.com:8440 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in E:\xampp\htdocs\test.php on line 2

You can simply block only the fsockopen function warnings/ notices or another errors from that line of the code by simply adding “@” symbol in the front of the variable or function, like this:

@$fp = fsockopen(“google.com”,”8440″,$errno,$errstr,5);

or like this:

$fp = @fsockopen(“google.com”,”8440″,$errno,$errstr,5);

Hope this helps you, thanks for reading my tutorial.