<?php
function isPortOpen(string $host, int $port, float $timeoutSec = 2.0): bool {
$fp = @fsockopen($host, $port, $errno, $errstr, $timeoutSec);
if ($fp) { fclose($fp); return true; }
return false;
}
var_dump(isPortOpen('google.com', 443)); // true
var_dump(isPortOpen('google.com', 12345)); // false
var_dump(isPortOpen('localhost', 3306)); // true if MySQL is running locally
Create a free account and build your private vault. Share publicly whenever you want.