PHP取得MAC地址 
<?php // 在linux下面取得MAC地址// 在windows下面需要外部mac.exe,// mac . exe为返回MAC地址的可执行程序,这个你们可以自己用DELPHi或者VC写 /// 作者 hisun  <[email protected]>// 任何疑问,请到 <a href="http://www.hisunweb.com" target="_blank">www.hisunweb.com</a> 留言,谢谢!// 请尊重作者劳动成果if ($_ENV["OS"] == "Windows_NT") {    function getMAC($nic = "lo")    {        $mac_exe_file = "e:\mac.exe";        if ($nic == 'lo') return "000000000000";        if ($nic != 'eth0') {            return false;        }         $s1 = trim(shell_exec($mac_exe_file));        return strtolower($s1);    } } else {    function getMAC($nic = "lo")    {        if ($nic == 'lo') return "000000000000";        $s1 = shell_exec("/sbin/ifconfig " . escapeshellarg($nic) . " | head -1");        if (strpos($s1, 'HWaddr') <= 1) {            return false;        } else {            $a = explode('HWaddr', $s1);            $s2 = str_replace(":", "", trim($a[1]));            return strtolower($s2);        }     } } // echo "lo=>".getMAC()."<br>";echo "eth0=>" . getMAC('eth0') . "<br>";echo "eth1=>" . getMAC('eth1') . "<br>";?> 

解决方案 »

  1.   

    如下内容存为xx.vbs文件,双击xx.vbs文件运行后可得到MAC,但要用在html中要有很大的权限。
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set IPConfigSet = objWMIService.ExecQuery _
        ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=true")
    For Each IPConfig In IPConfigSet
    s = ""
            ss = ""
            For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
                ss = ss & IPConfig.IPAddress(i) & "  "
            Next
      s = s & "IPAddress:  " & ss & vbCrLf
      s = s & "MACAddress:  " & IPConfig.MACAddress & vbCrLf
    MsgBox s
    Next
      

  2.   

    不清楚你是要服务端还是客户端的,是服务端的话,服务器是UNIX还是WIN,我这里给你提一下一个最初做过的简单的思路,
    LINUX/BSD下,就用最老土的方法(当初我初学啊,嘻)
    用exec()去调用ifconfig命令,把结果集保存,再进行正则分析,取得ETHER后面的值就可以,这个在服务端比较容易,呵呵,下次问问题时,说清楚一下,好回答
      

  3.   

    获取客户端的网卡mac地址:<?php@exec("arp -a",$array);
    for($Tmpa;$Tmpa<count($array);$Tmpa++){
          if(eregi($REMOTE_ADDR,$array[$Tmpa])){
                $mac=explode($REMOTE_ADDR,$array[$Tmpa]);
                echo $mac[1];
          }
    }
    echo $REMOTE_ADDR;
    ?>