SOOOO這又是我這個功能..不檢查域名只
我有功能的工作。
function http_file_exists($url)
{
$f = @fopen($url,"r");
if($f)
{
fclose($f);
return true;
}
return false;
}
這是用法:
if ($submit || $preview || $refresh)
{
$post_data['your_url'] = "http://www.google.com/this"; //remove the equals and url value if using in real post
$your_url = $post_data['your_url'];
$your_url_exists = (isset($your_url)) ? true : false;
$your_url = preg_replace(array('#&\#46;#','#&\#58;#','/\[(.*?)\]/'), array('.',':',''), $your_url);
if ($your_url_exists && http_file_exists($your_url) == true)
{
trigger_error('exists!');
}
我如何讓它檢查整個網址,而不僅是域名?例如http://www.google.com/this
即使我發佈該網址http://www.google.com/abadurltotest – wadie 2012-01-30 12:58:45
也不會觸發錯誤,因爲它只會觸發一個好的網址,而不是一個不好的網址。 '如果($ your_url_exists && http_file_exists($ YOUR_URL)===假) { trigger_error( '對不起,那是進入了一個糟糕的網址,請按返回鍵,並用有效的URL再試一次!'); }' – 2012-01-30 17:07:56
不,還是一樣的。不知道什麼是錯的。我首先發布的那個工作更好一點。我會研究它:\ – wadie 2012-01-30 17:28:54