Manuel Pear

setMAC()

setMAC() -- Sets the MAC address in the object

Synopsis

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

mixed setMAC (chaîne de caractères $macaddr, chaîne de caractères $delimiter = ':')

Description

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.

Paramètres

  • chaîne de caractères $macaddr - The chaîne de caractères representing the MAC address

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

Valeur retournée

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

Note

Cette fonction ne peut pas être appelée de façon statique.

Exemple

Exemple 54-1. Using setMAC()

  1. <?php
  2. require_once 'Net/MAC.php';  
  3. require_once 'MDB2.php';  
  4.  
  5. $db_type = 'pgsql';  
  6. $db_host = 'localhost';  
  7. $db_user = 'username';  
  8. $db_name = 'dbname';  
  9. $db_pass = 'password';  
  10.  
  11. $dsn = "$db_type://$db_user:$db_pass@$db_host/$db_name";  
  12.  
  13. $dbh =& MDB2::factory($dsn);  
  14.  
  15. if (MDB2::isError($dbh)) {  
  16. echo "MDB2 Error: ".$dbh->getUserInfo();  
  17. }  
  18.  
  19. $dboptions = array('tablename' => 'macvendors', 
  20.             'macaddrcol' => 'macaddr', 
  21.             'vendorcol' => 'vendor', 
  22.             'desccol' => 'description');  
  23.  
  24. try {  
  25. $nmh =& new Net_MAC($dbh, $dboptions);  
  26. } catch (Net_MAC_Exception $e) {  
  27. echo 'Net_MAC Error: ' . $e->getMessage();  
  28. exit;  
  29. }  
  30.  
  31. $nmh->setMAC('00:11:22:33:44:55'  
  32. ?> 

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