PHP检查输入中的验证URL

时间:2014-04-08 18:19:53

标签: php validation url

我需要帮助如何使用php检查URL的验证

<?php 
if (isset($_POST['submit'])) {
$url = htmlspecialchars($_POST['url']);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($code == 200) {
            echo "<div style='color: rgb(22, 146, 22); padding: 5px 10px; background-color: rgb(158, 234, 158); border-radius: 3px; background-clip: padding-box; box-shadow: 0px 0px 0px 1px rgba(0, 255, 30, 0.25); font-size: 12px; line-height: 15px;'><center>$url Up :)</center></div>";

} else {
            echo "<div style='color: #BD2727; padding: 5px 10px; background-color: #FFD6D6; border-radius: 3px; background-clip: padding-box; box-shadow: 0px 0px 0px 1px rgba(189, 39, 39, 0.25); font-size: 12px; line-height: 15px;'><center>$url Down :(</center></div>";
}
    }
}?>

请帮帮我

0 个答案:

没有答案