How to get system Mac Address in PHP

Today i will explain you a short PHP snippet to get the computer mac address using PHP. This is very simple PHP function. We will trigger the system commend and get the mac address.

PHP get client machine mac address

You can view demo and download how get system Mac Address using PHP:


// Turn on output buffering
//Get the ipconfig details using system commond
system('ipconfig /all');

// Capture the output into a variable
// Clean (erase) the output buffer

$findme = "Physical";
//Search the "Physical" | Find the position of Physical text
$pmac = strpos($mycom, $findme);

// Get Physical Address
//Display Mac Address
echo $mac;

//If you want you can track the page visitor's mac address and store in database
//Insert the visitor's mac address to database
// " INSERT INTO `table_name` (`column_name`) VALUES('".$mac_address."') ";

This is a simple and effective way of getting the client system Mac address using PHP. Hope it will help you. :)

6 Comments How to get system Mac Address in PHP

  1. Gopala krishnan

    Hi i’am from Chennai – India, i need to retrieve mobile number of the users who visited my website using PHP.

    1. Prasad G K

      You have to put a form and ask them to enter their mobile number. If it’s mandatory for you means put a popup where you can place this form. Validate this form in such a way that, Users can enter your website only after providing their mobile number.

      1. Junita Sari

        Hai, I am Juni from Indonesia.
        I need to know any mac address from device who visited my php website. can i do that? and how?
        Thanks before.

        1. Prasad G K

          Hi Juni,

          I have modified this post code and showed how can you tack the visitor’s mac address and store in database. Hope this will help you.


Leave a Reply to Vibhor Cancel reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>