如何在PHP中获取计算机的mac地址?

Ste*_*ons 1 php

如何在PHP中获取计算机的mac地址?

mar*_*rio 5

PHP本身不提供查找功能.您需要调用特定于平台的工具来获取信息,然后将其解压缩:

$text = `ifconfig`;
preg_match('/([0-9a-f]{2}:){5}\w\w/i', $text, $mac);
$mac = $mac[0];
Run Code Online (Sandbox Code Playgroud)

在Windows上,您可以使用ipconfig某些选项.