20 pers. connectées au site
Manuel Pear
setMAC()
setMAC() -- Sets the MAC address in the object
Synopsis
- <?php
- require_once 'Net/MAC.php
- ?>
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()
- <?php
- require_once 'Net/MAC.php';
- require_once 'MDB2.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)) {
- echo "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) {
- echo 'Net_MAC Error: ' . $e->getMessage();
- exit;
- }
-
- $nmh->setMAC('00:11:22:33:44:55'
- ?>
|
Remonter