I have a function that needs to ping 5 machines on the internal network. I am using the command below:
//EXECUTA O PING
exec("ping " . $host, $output, $result);
What happens is as follows. If I put a non-standard ip, such as "192.999.999.999" the function test, below, correctly returns that does not exist (OFF):
// TESTA O RESULTADO
if ($result == 0) {
echo "ON";
} else {
echo "OFF";
}
Now, if I put a correct ip, but that is only offline, it always returns me ON. If the ip is even online it also returns me ON, which is correct.
Is there any other way to use this ping in PHP? So that it recognizes when ip is offline?