Specific example of obtaining MAC address with PHP_PHP tutorial

WBOY
Release: 2016-07-13 17:18:11
Original
869 people have browsed it

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...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!