php执行ping命令

作者: zengde 分类: php 发布时间: 2021-03-26 10:59
<meta charset='utf-8'>
<?php
$descriptorspec = [
    ['pipe','r'],
    ['pipe','w'],
    ['pipe','w'],
];
$commmand='ping baidu.com';
$process=popen($commmand,'r');
while($b=fgets($process,2028)){
    echo iconv('gbk','utf-8',$b),'<br>';
    ob_flush();
    flush();
}
pclose($process);