PHP code example of blake-gardner / mac-address
1. Go to this page and download the library: Download blake-gardner/mac-address library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
blake-gardner / mac-address example snippets
php
// e_once './src/BlakeGardner/MacAddress.php';
// import the class
use BlakeGardner\MacAddress;
// get the mac address of the eth0 interface
var_dump(MacAddress::getCurrentMacAddress('eth0'));
// generate a random mac address
var_dump(MacAddress::generateMacAddress());
// validate an MAC address
var_dump(MacAddress::validateMacAddress('00-B0-D0-86-BB-F7'));
// set a randomly generated MAC address on the eth0 interface
var_dump(MacAddress::setFakeMacAddress('eth0'));
// set a specific MAC address on the eth0 interface
var_dump(MacAddress::setFakeMacAddress('eth0', '00:E4:01:2C:79:DA'));
// get the mac address of the eth0 interface using the ifconfig path that we define
var_dump(MacAddress::getCurrentMacAddress('eth0', '/usr/local/sbin/ifconfig'));
echo "\n";