如何在局域网连接机器上获取mac地址? [英] How to get mac address on lan connected machine?
问题描述
我正在尝试在LAN连接的机器上获取mac地址,但我收到以下错误,
已成功连接没有找到127.0.0.1的mac地址
我尝试了什么:
我试过这段代码,< br $>
<?php
$ link = mysqli_connect('localhost ','mysql_user','');
if(!$ link)
{
die('无法连接:'。 mysql_error());
}
echo'连接成功';
mysqli_close($ link);
$ ip = $ _SERVER ['REMOTE_ADDR'];
$ mac = shell_exec('arp -a'。escapeshellarg($ ip) ));
$ findme =物理;
$ pos = strpos($ mac,$ findme);
$ macp = substr ($ mac,($ pos + 42),26);
if(空($ mac))
{
die(找不到$ ip的mac地址);
}
echo$ ip:$ macp的mac地址;
?>
I am trying to get the mac address on LAN connected machine but I have got the following error,
Connected successfullyNo mac address for 127.0.0.1 not found
What I have tried:
I have tried this code,
<?php
$link = mysqli_connect('localhost', 'mysql_user', '');
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysqli_close($link);
$ip = $_SERVER['REMOTE_ADDR'];
$mac = shell_exec('arp -a'. escapeshellarg($ip));
$findme = "Physical";
$pos = strpos($mac, $findme);
$macp = substr($mac,($pos+42),26);
if(empty($mac))
{
die("No mac address for $ip not found");
}
echo "mac address for $ip: $macp";
?>
推荐答案
link = mysqli_connect('localhost','mysql_user','');
if(!
link = mysqli_connect('localhost', 'mysql_user', '');
if (!
link)
{
die('无法连接:'。 mysql_error());
}
echo'Connected successfully';
mysqli_close(
link)
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysqli_close(
link );
link);
这篇关于如何在局域网连接机器上获取mac地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!