background image

 

PHP 代码:php js 获取客户端 mac 地址的实现代码

本文主要为大家分享如何在 php 与 js 中分别获取客户度 mac 地址的方法,有兴趣的朋友
可以参考下
直接上代码吧!
代码如下:

<?php   

class

 MacAddr 

{   

    

public

 

$returnArray

 = 

array

();    

    

public

 

$macAddr

;   

 

    

function

 __contruct(

$os_type

=null){ 

        

if

(

is_null

(

$os_type

)) 

$os_type

 = PHP_OS;   

        

switch

 (

strtolower

(

$os_type

)){   

        

case

 "linux":   

            

$this

->forLinux();   

            

break

;   

        

case

 "solaris":   

            

break

;   

        

case

 "unix":   

            

break

;   

        

case

 "aix":   

            

break

;   

        

default

:   

            

$this

->forWindows();   

            

break

;   

        

}   

        

$temp_array

 = 

array

();   

        

foreach

(

$this

->returnArray 

as

 

$value

 ){   

            

if

(preg_match("/[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f]

[0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f]/i", 

$value

$temp_array

)){   

                

$this

->macAddr = 

$temp_array

[0];   

                

break

;   

            

}   

        

}   

        

unset(

$temp_array

);   

        

return

 

$this

->macAddr;