[問題] 語法請教
看板RegExp (正規表示式 Regular Expression)作者tonytsai88 (我愛吃涼麵)時間15年前 (2009/11/22 19:18)推噓0(0推 0噓 0→)留言0則, 0人參與討論串1/2 (看更多)
請問下面這個 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
討論串 (同標題文章)
RegExp 近期熱門文章
PTT數位生活區 即時熱門文章