VIEWED

  1. 你没有浏览过任何文章或者你没有开启cookies。

Posts Tagged ‘fopen’

【PHP,JS】判断URL地址是否有效

php中可以通过好几个函数来判断字符串的URL地址是否有效

if(@file_get_contents("http://community.csdn.net/ui/homepage/images/questions.gif")) echo 'Y'; else echo 'N';

或者

if(@fopen("http://community.csdn.net/ui/homepage/images/questions.gif")) echo 'Y'; else echo 'N';

很方便 而JS可以这样(只兼容IE,兼容FF的需要AJAX实现)

function isExist(url) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") xmlhttp.open("GET",url,false) xmlhttp.send() if(xmlhttp.status==200) return true; else return false; }

也很方便

......[ More Detail ]