2016-04-11

【PHP】ping 網路設備是否連線

 
<?php
exec('ping -c 2 192.200.6.19',$output);
print_r($output);
?>
 

結果會存在陣列 $output 內,再透過 print_r() 顥示陣列內容
 
Array
(
    [0] => PING 192.200.6.19 (192.200.6.19) 56(84) bytes of data.
    [1] => 64 bytes from 192.200.6.19: icmp_seq=1 ttl=128 time=0.228 ms
    [2] => 64 bytes from 192.200.6.19: icmp_seq=2 ttl=128 time=0.183 ms
    [3] => 
    [4] => --- 192.200.6.19 ping statistics ---
    [5] => 2 packets transmitted, 2 received, 0% packet loss, time 1000ms
    [6] => rtt min/avg/max/mdev = 0.183/0.205/0.228/0.026 ms
)
 

沒有留言:

張貼留言