How to get MAC address of client using PHP?

前端 未结 10 1619
长情又很酷
长情又很酷 2020-11-28 08:39

How can I get MAC Address using PHP or javascript...

10条回答
  •  渐次进展
    2020-11-28 09:09

    Use this function to get the client MAC address:

    function GetClientMac(){
        $macAddr=false;
        $arp=`arp -n`;
        $lines=explode("\n", $arp);
    
        foreach($lines as $line){
            $cols=preg_split('/\s+/', trim($line));
    
            if ($cols[0]==$_SERVER['REMOTE_ADDR']){
                $macAddr=$cols[2];
            }
        }
    
        return $macAddr;
    }
    

提交回复
热议问题