|
 |
11³â Àü |
// url¿¡ http:// ¸¦ ºÙÀδÙ
if (!preg_match("/^(http|https|ftp|telnet|news|mms)\:\/\//i", $url))
$url = "http://" . $url;
<?php
$urls = Array();
$urls[] = 'http://apmusers.com/';
$urls[] = 'https://apmusers.com/';
$urls[] = 'HTTP://APMUSERS.COM/';
$urls[] = 'ahttp://apmusers.com/';//http:// ¾Õ¿¡ ´Ù¸¥ ¹®ÀÚ°¡ ÀÖ´Ù.
$urls[] = 'b http://apmusers.com/';//htpp:// ¾Õ¿¡ ´Ù¸¥ ¹®ÀÚ¿Í °ø¹éÀÌ ÀÖ´Ù.
$urls[] = 'http:/apmusers.com/'; //http:/ ´ÙÀ½¿¡ / Çϳª ¾ø´Ù
foreach($urls as $url){
echo $url . ' ==> ';
//url ÀÇ Á¦ÀÏ ¾Õ¿¡ ´ë¼Ò¹®ÀÚ ±¸ºÐ¾øÀÌ http:// ³ª https:// °¡ Á¸ÀçÇÏ´ÂÁö È®ÀÎ
if (preg_match("`^https?://`i", $url)) {
echo "<font color='blue'>Á¦ÀÏ ¾Õ¿¡ http(s):// °¡ ÀÖ´Â »ç¿ë °¡´ÉÇÑ URL ÀÔ´Ï´Ù.</font> <br />" . PHP_EOL;
}
else {
echo "<font color='red'>Á¦ÀÏ ¾Õ¿¡ http(s):// °¡ ¾ø´Â »ç¿ë ºÒ°¡´ÉÇÑ URL ÀÔ´Ï´Ù.</font> <br />" . PHP_EOL;
}
}
?>
<?
$domain="www.naum.kr";
preg_match('/[^\.]+\.([^\.]{4}|[^\.]{3}|(co|or|pe|ac)\.[^\.]{2}|[^\.]{2})$/i', $domain, $matches);
print_r($matches);
?>
|
|
̵̧ : 414 |
̵̧
¸ñ·Ï
|
|