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

May 1, 2010
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;

?>

Comments

One Comment on PHP: How to Get MAC Address for Current System Using PHP

  1. Suman on Sat, 25th Dec 2010 8:43 am
  2. i will shut down all computers in world… if the above thing works

Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!





*
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