Function not working correctly

Now I usually don’t use functions but I am just trying them out.

Now what I am trying to do is make it easy to execute the function using the defined values but it always returns as online regardless of the value I use.

[php]function grabStatus($server, $portn) {
$ip = “$server”;
$port = “$portn”;
echo “Server:”;
if (! $sock = @fsockopen($ip, $port, $num, $error, 5)) {
echo “Online”;
} else {
echo “Offline”;
}
}

grabStatus(/* a server ip */, 8023); //randomly picked port that is not being utilized
[/php]

I’d appreciate help. I do understand how functions work to an extent, I just don’t know why this isn’t working for me.

look at what you have. its going to report back that its online because its being told that if it fails that the server is online. just remove the ! and it should say that its offline.

Sponsor our Newsletter | Privacy Policy | Terms of Service