<?php $text = "http://www.yahoo.co.jp/"; if (preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $text)) { echo "正しいURLです"; } else { echo "正しくないURLです"; } ?> <?php function is_url($text) { if (preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $text)) { return TRUE; } else { return FALSE; } } ?>