Ping function having undesirable results
<p>I previously asked this question <a href="http://stackoverflow.com/questions/8030789/pinging-an-ip-address-using-php-and-echoing-the-result">here</a> on how to create a ping function and came up with the follow:</p>

<pre><code>&lt;?php
function pingAddress($ip) {
    $pingresult = exec("ping -n 3 $ip", $outcome, $status);
    if (1 != $status) {
        $status = "alive";
    } else {
        $status = "dead";
    }
    echo "The IP address, $ip, is  ".$status;
}
</code></pre>

<p>This had the desired results until I noticed that it was returning IP address 192.168.0.3 as alive when I knew it wasn't.</p>

<p>I checked through my standard windows command prompt and it was returning the following:</p>

<pre><code>Reply from 192.168.0.2: Destination host unreachable.
Reply from 192.168.0.2: Destination host unreachable.
Reply from 192.168.0.2: Destination host unreachable.
Reply from 192.168.0.2: Destination host unreachable.
</code></pre>

<p>I'm assuming that the function think its alive due to the way its written and how it returns 'Reply from'? However I'm not too sure - can anyone shed some light on it?</p>

<p>Thanks</p>
