3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * Getting MAC Address using PHP * Md. Nazmul Basher */ ob_start(); // Turn on output buffering system('/sbin/ifconfig | grep HWaddr'); //Execute external program to display output $mycom=ob_get_contents(); // Capture the output into a variable ob_clean(); // Clean (erase) the output buffer echo $mycom;die; $findme = 'Physical'; $pmac = strpos($mycom, $findme); // Find the position of Physical text $mac=substr($mycom,($pmac+36),17); // Get Physical Address echo $mac;

preferences:
34.05 ms | 402 KiB | 5 Q