在localhost中成功获取mac(系统物理地址)地址,但在服务器中不成功

问题描述 投票:0回答:2

我想要客户端的mac(系统物理地址)地址,我得到了它但是当我在服务器中托管时没有得到任何东西。

我用来获取mac地址的代码是:

ob_start();  

system('ipconfig /all');  

$mycomsys=ob_get_contents();  

ob_clean();  

$find_mac = "LAN Card"; 

$pmac = strpos($mycomsys, $find_mac); 

$macaddress=substr($mycomsys,($pmac+49),17);  

echo $macaddress;  

我不知道我哪里出错了。请帮我解决这个问题。

javascript php mysql
2个回答
0
投票

您的服务器上运行的是什么系统?如果它不是Windows,其他系统(Linux等)不理解/ all。如果是Windows,请注意不要将服务器卡称为“LAN卡”。首先看一下ifconfig的完整输出。


-1
投票

如果您使用Windows服务器。然后尝试这段代码。

<?php
ob_start();  

system('ipconfig /all');  

$mycomsys=ob_get_contents();  

ob_clean();  

$find_mac = "Physical Address"; 

$pmac = strpos($mycomsys, $find_mac); 

$macaddress=substr($mycomsys,($pmac+35),17);  

echo $macaddress;  
© www.soinside.com 2019 - 2024. All rights reserved.