setMAC() – Sets the MAC address in the object


require_once 'Net/MAC.php';

mixed setMAC ( string $macaddr , string $delimiter = ':' )


This method will set the MAC address in the object given the passed MAC address and the MAC address delimiter. This method also makes use of the check() method to make sure that the MAC address is valid.


  • string $macaddr - The string representing the MAC address

  • string $delimiter - The string representing the delimiter to use when verifying the MAC Address

Return value

boolean - Returns TRUE if the MAC address is set correctly, FALSE otherwise (i.e. the MAC address is not valid).


This function can not be called statically.


Using setMAC()

require_once 'Net/MAC.php';

$db_type 'pgsql';
$db_host 'localhost';
$db_user 'username';
$db_name 'dbname';
$db_pass 'password';

$dsn "$db_type://$db_user:$db_pass@$db_host/$db_name";

$dbh =& MDB2::factory($dsn);

if (
MDB2::isError($dbh)) {
"MDB2 Error: ".$dbh->getUserInfo();

$dboptions = array('tablename' => 'macvendors',
'macaddrcol' => 'macaddr',
'vendorcol' => 'vendor',
'desccol' => 'description');

try {
$nmh =& new Net_MAC($dbh$dboptions);
} catch (
Net_MAC_Exception $e) {
'Net_MAC Error: ' $e->getMessage();

Constructor (Previous) Import a manufacturers' file to the database or to an array (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.