2016-04-11

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

  1.  
  2. <?php
  3. exec('ping -c 2 192.200.6.19',$output);
  4. print_r($output);
  5. ?>
  6.  

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

沒有留言:

張貼留言