i have this simple code that i want to check if port 80 is open/up but when it can't connect it stops the entire page from loading, how do I just echo "offline" when it can't connect and not something like this:
Warning: fsockopen() [function.fsockopen]: php_hostconnect: connect failed in /home/public_html/stats.php on line 365
Warning: fsockopen() [function.fsockopen]: unable to connect to 127.0.0.1:82 in /home/public_html/stats.php on line 365
thanx.
$fp = fsockopen ("127.0.0.1", 80, $errno, $errstr, 10);
if (!$fp) {
echo "HTTP <font color=\"red\"><b>offline</b>";
} else {
echo "HTTP <font color=\"lime\"><b>online</b>";
}
fclose ($fp);