getServerIp();
function getServerIp()
{
$result = shell_exec("ip addr | grep inet ");
$resultArray = explode("\n",$result);
$serverIpString = $resultArray[2];
$serverIpString = explode("/",$serverIpString)[0];
$serverIp = str_replace(" ","",$serverIpString);
$serverIp = str_replace("inet","",$serverIp);
return apiJson(1,"success",$serverIp);
}
function apiJson($code,$msg,$data=[])
{
header("Content-Type:application/json;charset=utf8");
$returnData=[];
$returnData['code'] = $code;
$returnData['msg'] = $msg;
if ($data) {
$returnData['data'] = $data;
}
echo json_encode($returnData);
}
转载请注明原文地址:https://blackberry.8miu.com/read-2767.html