How can PHP be used to check if a specific computer in a network is on or off?

To check if a specific computer in a network is on or off, you can use PHP to send a ping request to the IP address of the target computer. If the computer is on and reachable, it will respond to the ping request. If there is no response, the computer may be off or unreachable.

<?php
$ip = '192.168.1.100'; // IP address of the target computer
exec("ping -c 1 $ip", $output, $result);
if ($result == 0) {
    echo "Computer is on and reachable";
} else {
    echo "Computer is off or unreachable";
}
?>