Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17211 программистов и 1834 робота. Сейчас ищут 1624 программиста ...
Net_MAC::check()
Вернуться к: Net_MAC
Net_MAC::check()
Net_MAC::check() – Validates Media Access Control (MAC) addresses
Synopsis
require_once 'Net/MAC.php';
string Net_MAC::check ( string $input , string $delimiter=':' )
This function will check a MAC address to make sure it is valid.
Parameter
-
string $input - The string containing the MAC Address
-
string $delimiter - The string representing the delimiter to use when checking the MAC Address
Return value
boolean - TRUE if the MAC address is valid, FALSE otherwise
Note
This function should be called statically.
Example
Using check()
<?php
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
Using check() to get a MAC address with a different delimiter
<?php
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.
Вернуться к: Net_MAC