share a case of PHP to get the MAC address of the code, learn how to read the hardware information in PHP, the code for Windows, Linux systems. Have a friend in need of reference study under
This section shares the PHP code, the main function: Get the Machine network card Physical (MAC) address. Code: Code as follows: <?php /** * Acquire the physical (MAC) address of the Machine network card * currently supports Win/linux system **/ class Macaddinfo { var $return _array = Array ();//return string array with MAC address &NBS P var $mac _addr; function macaddinfo ($os _type) { switch (strtolower $os _ty PE) { case "Linux": & nbsp $this->forlinux (); break; case "Solaris": break; case "UNIX": &NB Sp Break Case "AIX": break; default: $this->forwindows (); break; } $temp _array = Array (); foreach ($this->return_array as $value) { &NBS P 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->ma C_ADDR = $temp _array [0]; break; { &NBSp unset ($temp _array); return $this->mac_addr; } function forwindows () { @exec ("IPC Onfig/all ", $this->return_array); if ($this->return_array) return $th is->return_array; else { $ipconfig = $_server ["windir"] . "/system32/ipconfig.exe"; if (Is_file ($ipconfig)) &NBS P @exec ($ipconfig. "/all", $this->return_array); else @exec ($_server ["windir"]. "/system/ipconfig.exe/all", $this->return_array); return $this->return_array; { } function Forlinux () { &NBSP ; @exec ("Ifconfig-a", $this->return_array); return $this->return_array; } } //Call example//$mac = new Macaddinfo (php_os); //echo $mac->mac_addr; ?>