作者tonytsai88 (我爱吃凉面)
看板RegExp
标题[问题] 语法请教
时间Sun Nov 22 19:18:10 2009
请问下面这个 preg_match 的用法怎麽拆解?
/**
* Validate that a hostname (for example $_SERVER['HTTP_HOST']) is safe.
*
* As $_SERVER['HTTP_HOST'] is user input, ensure it only contains characters
* allowed in hostnames. See RFC 952 (and RFC 2181). $_SERVER['HTTP_HOST'] is
* lowercased.
*
* @return
* TRUE if only containing valid characters, or FALSE otherwise.
*/
function drupal_valid_http_host($host) {
return preg_match('/^\[?(?:[a-z0-9-:\]_]+\.?)+$/', $host);
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.132.186.59