I am a newbie at PHP so I am wondering if anyone could help me.
I made a script using lots of work, even tough it's really easy but I just suck.
But yeah, if my website is on, this scripts shows it.
But if it doesn't load it takes a million hours for it to say that.
How can I set the maximum time for the script?
Thank you verry much
(I've searched a lot around Stack Overflow for a solution to this and all answers I found were unclear or not working for me.)
<?php
$host = '127.0.0.1';
$ports = array(3000, 80);
foreach ($ports as $port)
{
$connection = @fsockopen($host, $port);
if (is_resource($connection))
{
if($port == 80)
{
echo "web: ONLINE";
}
if($port == 3000)
{
echo 'client: ONLINE';
}
fclose($connection);
}
else
{
echo '<h2>' . $host . ':' . $port . ' is not responding.</h2>' . "\n";
}
}
?>