1--TEST-- 2filter_var() and FILTER_VALIDATE_MAC 3--SKIPIF-- 4<?php if (!extension_loaded("filter")) die("skip"); ?> 5--FILE-- 6<?php 7$values = Array( 8 array("01-23-45-67-89-ab", null), 9 array("01-23-45-67-89-ab", array("options" => array("separator" => "-"))), 10 array("01-23-45-67-89-ab", array("options" => array("separator" => "."))), 11 array("01-23-45-67-89-ab", array("options" => array("separator" => ":"))), 12 array("01-23-45-67-89-AB", null), 13 array("01-23-45-67-89-aB", null), 14 array("01:23:45:67:89:ab", null), 15 array("01:23:45:67:89:AB", null), 16 array("01:23:45:67:89:aB", null), 17 array("01:23:45-67:89:aB", null), 18 array("xx:23:45:67:89:aB", null), 19 array("0123.4567.89ab", null), 20 array("01-23-45-67-89-ab", array("options" => array("separator" => "--"))), 21 array("01-23-45-67-89-ab", array("options" => array("separator" => ""))), 22); 23foreach ($values as $value) { 24 var_dump(filter_var($value[0], FILTER_VALIDATE_MAC, $value[1])); 25} 26 27echo "Done\n"; 28?> 29--EXPECTF-- 30string(17) "01-23-45-67-89-ab" 31string(17) "01-23-45-67-89-ab" 32bool(false) 33bool(false) 34string(17) "01-23-45-67-89-AB" 35string(17) "01-23-45-67-89-aB" 36string(17) "01:23:45:67:89:ab" 37string(17) "01:23:45:67:89:AB" 38string(17) "01:23:45:67:89:aB" 39bool(false) 40bool(false) 41string(14) "0123.4567.89ab" 42 43Warning: filter_var(): Separator must be exactly one character long in %s055.php on line %d 44bool(false) 45 46Warning: filter_var(): Separator must be exactly one character long in %s055.php on line %d 47bool(false) 48Done 49