Created
August 17, 2011 15:50
-
-
Save JunaidQadirB/1151838 to your computer and use it in GitHub Desktop.
Getting MAC Address of the host using PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMAC() | |
{ | |
/* | |
* Getting MAC Address of the host using PHP | |
* Md. Nazmul Basher | |
* Modified by Junaid Qadir Baloch | |
* Now this function gets all the MAC addresses attached to the system | |
* on which this function is called in an array and returns. | |
*/ | |
ob_start(); // Turn on output buffering | |
system('ipconfig /all'); //Execute external program to display output | |
$mycom=ob_get_contents(); // Capture the output into a variable | |
ob_clean(); // Clean (erase) the output buffer | |
foreach(preg_split("/(\r?\n)/", $mycom) as $line){ | |
if(strstr($line, 'Physical Address')) | |
{ | |
$Mac[]= substr($line,39,18); | |
} | |
} | |
return $Mac; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code will give us the server mac address not client mac