PHP - 让服务器ping访问者IP并以ms为单位返回ping [英] PHP - get server to ping a visitors IP and return the ping in ms
本文介绍了PHP - 让服务器ping访问者IP并以ms为单位返回ping的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想按标题说明。要ping用户IP并以ms为单位返回结果,例如:
I want to do as the title states. To ping a users IP and return a result in ms, for instance:
Ping IP
返回400ms。
Ping IP return 400ms.
我不知道怎么做但我希望它会相对简单。我可以访问exec()函数和类似的函数,因为我将在虚拟专用服务器上运行此脚本。
I have no idea how to do this but I expect it would be relatively simple. I have access to the exec() function and the functions similar to it as I will be running this script on a virtual private server.
提前致谢。
推荐答案
试试这个
<?php
$out = array();
exec('ping -c 4 '.$_SERVER['REMOTE_ADDR'], $out);
print_r($out);
?>
这篇关于PHP - 让服务器ping访问者IP并以ms为单位返回ping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文