<?php
# 取得輸入
$input = file_get_contents('php://input');
$input = json_decode($input, true);

# 組合 ping 指令
$target = $input['target'];
$cmd = "ping -c 1 -W 1 $target 2>&1";

# 執行 ping 指令
$content = shell_exec($cmd);

# 顯示回傳結果
echo $content;