How can I get the MAC and the IP address of a connected client in PHP?

前端 未结 16 2584
长发绾君心
长发绾君心 2020-11-22 02:29

I need to know the MAC and the IP address of the connect clients, how can I do this in PHP?

16条回答
  •  执笔经年
    2020-11-22 03:01

    You can use the following solution to solve your problem:

    $mac='UNKNOWN';
    foreach(explode("\n",str_replace(' ','',trim(`getmac`,"\n"))) as $i)
    if(strpos($i,'Tcpip')>-1){$mac=substr($i,0,17);break;}
    echo $mac;
    

提交回复
热议问题