Saturday, August 29, 2015

Get Mac Address With PHP


get mac address with php

This post is to show you about Getting Mac Address or PC Address using PHP. This script will help you to display the Address of your computer. Based on this function I hope you will like it. Please take a look at live demo and to see your computer address.

Function (index.php)

function get_mac_address()
{
  ob_start(); 
  system('ipconfig /all'); 
  $mycom=ob_get_contents();
  ob_clean(); 
  $findme = "Physical";
  $pmac = strpos($mycom, $findme);

  return substr($mycom,($pmac+36),17);
}


Explanation

- ob_start() : Turn on output buffering
- system('ipconfig /all') : Get the ipconfig details using system commond.
- ob_get_contents() : Return the contents of the output buffer
- ob_clean() : clear or Erase output buffering.

Call the function (index.php)/ Demo

<?php get_mac_address(); ?>


I hope you will share if you think it is important.

Location: Phnom Penh, Cambodia

1 comment: