PHP gets the client mac address program code_PHP tutorial
WBOY
Release: 2016-07-13 10:46:50
Original
1368 people have browsed it
The mac address is the network card address. Generally, the user's mac address cannot be obtained. Because of security restrictions on the browser, it is almost impossible to obtain it. Here are two pieces of code for everyone to play with.
function forLinux(){
@exec("ifconfig -a", $this->returnArray);
return $this->returnArray;
} }
$mac = new MacAddr(PHP_OS);
echo $mac->macAddr;
echo " ";
// Get client
// linux
$command = "arp -a {$_SERVER['REMOTE_ADDR']}";
echo $command;
echo " ";
$result=`{$command}`;
// windows
$command = "nbtstat -a {$_SERVER['REMOTE_ADDR']}";
echo $command;
echo " ";
$result=`{$command}`;
print_r($result);
?>
There is no big problem in getting the server-side logic, but there may be permission issues.
When obtaining the client, it may be slow, and the execution of the arp/nbstat command will be slow.
The code is as follows
代码如下
复制代码
Copy code
Only applicable to IE browser, and there will be a warning prompt
http://www.bkjia.com/PHPjc/632908.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632908.htmlTechArticleThe mac address is the network card address. Generally, the user's mac address cannot be obtained because security restricts browsing. It is almost impossible to obtain the device, so I will give you two pieces of code below...
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