Manuel Pear

Net_MAC::check()

Net_MAC::check() -- Validates Media Access Control (MAC) addresses

Synopsis

  1. <?php
  2. require_once 'Net/MAC.php
  3. ?> 

chaîne de caractères Net_MAC::check (chaîne de caractères $input [, chaîne de caractères $delimiter=':'])

Description

This function will check a MAC address to make sure it is valid.

Paramètres

  • chaîne de caractères $input - The chaîne de caractères containing the MAC Address

  • chaîne de caractères $delimiter - The chaîne de caractères representing the delimiter to use when checking the MAC Address

Valeur retournée

booléen - TRUE if the MAC address is valid, FALSE otherwise

Note

Cette fonction devrait être appelée de façon statique.

Exemple

Exemple 54-1. Using check()

  1. <?php
  2. require_once "Net/MAC.php";  
  3.  
  4. $macaddr = 'AB:CD:EF:00:11:22';  
  5.  
  6. $mac = Net_MAC::check($macaddr);  
  7. if ($mac) { 
  8.    echo "$macaddris valid";  
  9. }  
  10. else { 
  11.    echo "$macaddris invalid";  
  12. ?> 

This would output the following:

ab:cd:ef:00:11:22 is valid

Exemple 54-2. Using check() to get a MAC address with a different delimiter

  1. <?php
  2. require_once "Net/MAC.php";  
  3.  
  4. $macaddr = 'AB:CD:EF:00:11:22';  
  5.  
  6. $mac = Net_MAC::check($macaddr, '-');  
  7. if ($mac) { 
  8.    echo "$macaddris valid";  
  9. }  
  10. else { 
  11.    echo "$macaddris invalid";  
  12. ?> 

This would output the following:

AB:CD:EF:00:11:22 is invalid

since the delimiter '-' was not used in the provided MAC address.


Remonter Remonter
L'éditeur javascript - CSS - Gentoo - Tutoriaux PHP - Tutoriels PHP - Bretagne - php - Moto - Kit graphique