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