How to detect the MAC address of a device in PHP
In this article, we will learn how to get the MAC address or physical address of a system using PHP.
First of all, let me clear the concept of the MAC address.
What is a MAC address?
It abbreviated as media access control. A MAC address is a unique id of a device in the network interface controller (NIC).
It is also known as a physical address, an Ethernet hardware address, and a hardware address.
Example:-
14-F6-D7-88-3E-29
How to get MAC address using system command in PHP
The system() command gathers the information from the configuration file (ipconfig file). From that information file, we have to access only the physical address. The script is as follows,
<?php //Buffering the output ob_start(); //Getting configuration details system('ipconfig /all'); //Storing output in a variable $configdata=ob_get_contents(); // Clear the buffer ob_clean(); //Extract only the physical address or Mac address from the output $mac = "Physical"; $pmac = strpos($configdata, $mac); // Get Physical Address $macaddr=substr($configdata,($pmac+36),17); //Display Mac Address echo $macaddr; ?>
Output:-
38-D6-E7-78-4E-29
In this way, we can extract the MAC address of a computer. If you have any doubts about this article, leave a comment below.
See also,
This is now working showing blank page. Please if you have any other solution please post it.
For future readers: Please note that this only runs on Windows, not on Linux (which is probably what your server is running) nor on macOS.
On Linux, you can find the MAC address using
ip neigh show
You could filter the output using grep, awk, or PHP’s preg_match and preg_replace. Although I don’t have code ready at the moment now, this should help you (and me) on the way!
it take my mcAfee VPN ADDRESS PLS SUGGEST