网址是否有效 [英] is URL valid or not
本文介绍了网址是否有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
什么是最好的方法检查PHP中是否存在网址?`
Possible Duplicate:
what is the best way to check if a Url exists in PHP ?`
我正在寻找一个在php中返回TRUE或FALSE的函数,无论URL是否有效.
I'm looking for a function that returns TRUE or FALSE in php, either the URL is valid or not.
isValidURL($ url);我认为那很简单...这将考虑所有可能的URL.
isValidURL($url); i think that simple... That would take into count all kind of URL possible.
有效,我希望它指向Web或其他类型文件的现有页面.它应该存在
By valid i want It to referes to an existing page of the web or other kind of files. It just should exist
推荐答案
<?php
$url = "http://stack*overflow.org";
if(filter_var($url, FILTER_VALIDATE_URL) === FALSE)
{
echo "Not valid";
}else{
echo "VALID";
}
?>
这不会检查 tlds
this does not check tlds though
这篇关于网址是否有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文