PHP: How to Get MAC Address for Current System Using 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;

?>

One thought on “PHP: How to Get MAC Address for Current System Using PHP”

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image