lifesign
9/25/2014 - 8:50 AM

php get client mac

php get client mac

<?php

function getClientMac($ip = '')
{
    if (empty($ip)) {
        return;
    }

    $command = sprintf("cat /proc/net/arp | grep %s | awk '{print $4}'", $ip);
    $fd = popen($command, 'r');
    $line = fgets($fd);
    pclose($fd);

    return trim($line);
}