Net_MAC::check() -- Validates Media Access Control (MAC) addresses
Description
This function will check a MAC address to make sure it is valid.
Return value
boolean - TRUE if the MAC address is
valid, FALSE otherwise
Note
This function should be called
statically.
Example
Example 51-1. Using check() require_once "Net/MAC.php";
$macaddr = 'AB:CD:EF:00:11:22';
$mac = Net_MAC::check($macaddr);
if ($mac) {
echo "$macaddr is valid";
}
else {
echo "$macaddr is invalid";
} |
This would output the following:
ab:cd:ef:00:11:22 is valid |
|
Example 51-2. Using check() to get a MAC address with a
different delimiter require_once "Net/MAC.php";
$macaddr = 'AB:CD:EF:00:11:22';
$mac = Net_MAC::check($macaddr, '-');
if ($mac) {
echo "$macaddr is valid";
}
else {
echo "$macaddr is invalid";
} |
This would output the following:
AB:CD:EF:00:11:22 is invalid |
since the delimiter '-' was not used in the provided MAC address.
|