One of my favorite network tool websites is YouGetSignal.com and recently I was using their open port tester to ensure my port forwarding rules were working. I started wondering how difficult it would be to setup an open port tester using PHP and turns out, it was really easy.
I’d like to share my basic working example below in case anyone has an interest or use for this as well. I did this using two files: portcheck.html and ports.php the port checker file is just a simple form that asks for the domain or host you want to test and then the port number you are testing. The action on this form points to the ports script which receives this request and then tests whether or not the port is open using the fsockopen PHP function.
Below is the source of portcheck.html:
Below is the source of ports.php:
Save both portcheck.html and ports.php in the same folder then visit portcheck.html in your browser. You should get a form that’s asking for a domain/host and a port number as shown in the screenshot below:
If you entered in google.com and port 80 then click submit, the ports script will test connectivity using fsockopen on google.com and port 80 then return the results as shown below: