Home  >  Article  >  Backend Development  >  Specific example of obtaining MAC address with PHP_PHP tutorial

Specific example of obtaining MAC address with PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:18:11871browse

The php code shared in this section has the main function:
Get the physical (MAC) address of the machine's network card.
Code:

Copy code The code is as follows:

/**
* Obtain the physical (MAC) address of the machine's network card
* Currently supports WIN/LINUX system
**/
class MacAddInfo { 
 var $return_array = array (); // Return a string array with MAC address  
 var $mac_addr; 

 function MacAddInfo($os_type) { 
  switch ( strtolower ( $os_type )) {
case "linux" :
$this->forLinux ();
case "solaris" :
             break; unix" :
break;
case "aix" :
break;
default :
$this-&g t;forWindows ();
                break;                                             $temp_array = array (); :-]" . "[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 )) {
                                                          
unset ( $temp_array );
         return $this->mac_addr;
if ($this->return_array)
return $this->return_array;
else {
$ipconfig = $_SERVER ["WINDIR"] . " ;
if (is_file ( $ipconfig ))
@exec ( $ipconfig . " /all", $this->return_array ); $_SERVER ["WINDIR" ] . "/system/ipconfig.exe /all", $this->return_array );
            return $this-> {
@exec ( "ifconfig -a", $this->return_array );
return $this->return_array;
}
}
//Calling example
//$mac = new MacAddInfo(PHP_OS);
//echo $mac->mac_addr;
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621689.htmlTechArticleThe php code shared in this section has the main function: Get the physical (MAC) address of the machine's network card. Code: Copy the code The code is as follows: ?php /** * Get the physical (MAC) address of the machine's network card * Currently...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn