检查是否存在HTML页面 [英] Check whether a HTML page exists

查看:115
本文介绍了检查是否存在HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查另一个站点上是否存在HTML页面.更确切地说,我的用户需要将.html页面上传到他们自己的网站上,然后他们需要在我的网站上按立即验证".然后,我的网站需要确认其网站上是否存在html页面.

I want to check whether a HTML page exists on another site. More exactly, my users need to upload a .html page onto their own site and after that they need to press "verify now" on my site. My site then needs to confirm that the html page exists on their site.

我找到了以下代码:

$url = 'http://domain.tld/my_page.html';
$handle = @fopen($url,'r');
if($handle !== false){
   echo 'Page Exists';
}  else {
   echo 'Page Not Found';
}

但是如果my_page.html不存在,则此代码仅返回页面已存在".

But if my_page.html don't exist, this code returns just "Page Exists".

推荐答案

假设您已在PHP中安装了curl扩展名,那么我认为到目前为止,这是您最好的选择: 轻松测试404网址的方法在PHP中?

Assuming that you have the curl extension installed in your PHP, I think this by far your best option: Easy way to test a URL for 404 in PHP?

这篇关于检查是否存在HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆