【问题标题】:check if link "still" exists [duplicate]检查链接“仍然”是否存在[重复]
【发布时间】:2012-11-30 23:29:36
【问题描述】:

可能重复:
How do I check for valid (not dead) links programatically using PHP?

我正在创建一个包含许多外部网站链接的网站,这些网站可能会关闭。

是否可以偶尔做一些压力测试,看看它们是否“还在那里”?

【问题讨论】:

标签: php javascript html sql


【解决方案1】:

可能会这样

function checkLink($link){ 
    flush(); 
    $fp = @fopen($link, "r"); 
    @fclose($fp); 
    if (!$fp){ 
        return "link is not active"; 
    }else{ 
        return "link is active"; 
    } 
} 

【讨论】:

  • 这个 allow_url_fopen 应该在 php.ini 配置中打开?
猜你喜欢
  • 1970-01-01
  • 2015-04-02
  • 2012-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多