PHP: How to Get MAC Address for Current System Using PHP

May 1, 2010 · 1 Comment
Filed under: Featured, PHP 



Here is the below code in PHP that is used to get MAC address in PHP

<?php

ob_start(); // Turn on output buffering

system('ipconfig /all'); //Execute external program to display output 

$capout=ob_get_contents(); // Capture the output into a variable 

ob_clean(); // Clean the output buffer

$findcurrentsystem = "Physical";

$pmac = strpos($capout, $findcurrentsystem); // Find the position of Physical text 

$mac=substr($capout,($pmac+36),17); // Get Physical Address

echo $mac;

?>