国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

php獲取網(wǎng)卡地址

2024-05-04 20:10:52
字體:
來源:轉載
供稿:網(wǎng)友

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php 
class Getmac{ 
    var $result array(); // 返回帶有MAC地址的字串數(shù)組 
    var $macAddr;
    /*構造*/
    function __construct($osType){ 
        switch strtolower($osType) ){ 
            case "unix"break;
            case "solaris"break;
            case "aix"break;
            case "linux": {
                $this->for_linux_os();
            }break
            default: { 
                $this->for_windows_os(); 
            }break
        
        $temp_array array(); 
        foreach($this->result 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; 
    }
    /*linux系統(tǒng)中獲取方法*/
    function for_linux_os(){ 
        @exec("ifconfig -a"$this->result); 
        return $this->result; 
    }
    /*win系統(tǒng)中的獲取方法*/
    function for_windows_os(){ 
        @exec("ipconfig /all"$this->result); 
        if $this->result ) {
            return $this->result;
        else 
            $ipconfig $_SERVER["WINDIR"]."/system32/ipconfig.exe";
            if(is_file($ipconfig)) {
                @exec($ipconfig." /all"$this->result);
            else {
                @exec($_SERVER["WINDIR"]."/system/ipconfig.exe /all"$this->result);
                return $this->result; 
            }
        
    
 
/*1.實現(xiàn)化類   2.直接訪問它的macAddr屬性*/
$getMac new Getmac(PHP_OS); 
echo $getMac->macAddr; 
?>

 

挺好用的!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 旺苍县| 盐山县| 利辛县| 潢川县| 涞源县| 柳江县| 阿拉尔市| 新绛县| 托克托县| 辽源市| 南皮县| 紫金县| 邵武市| 肇源县| 胶南市| 横峰县| 金平| 义马市| 南和县| 眉山市| 宁武县| 贵定县| 南通市| 西畴县| 芮城县| 汤原县| 天台县| 宝兴县| 澄江县| 平遥县| 洪洞县| 墨江| 松桃| 互助| 安泽县| 天柱县| 清丰县| 乡宁县| 苍溪县| 鸡泽县| 邓州市|