【发布时间】:2011-11-01 09:13:53
【问题描述】:
我想检查一个页面是否存在。我的文件是 article.php 。文章的网址是 article.php?id=1 article.php?id=2 等等。但是当我这样检查时它不起作用:
$filecheck = "article.php?id=$id";
if (file_exists($filecheck)) {
echo "This article exists.";
} else {
echo "Sorry this article does not exist.";
}
但它总是返回“对不起,这篇文章不存在”。 我该如何解决这个问题?
【问题讨论】:
-
为什么要将 query_string 添加到您的
$filecheckvar 中? -
除非你指定一个完整的
protocol://host/path/file类型的url,否则所有的文件函数都会假设你正在执行一个本地文件操作,并且你的代码正在寻找一个字面名称为article.php?id=XXX的文件,它不太可能存在。