作者allanshen (不要叫我宅男)
看板PHP
标题Re: [请益] 请问 file_exists 是不是只能找自己主븠…
时间Wed Aug 29 15:01:44 2007
※ 引述《phpasp (就是要嘘 大XD)》之铭言:
: 我用 file_exists 去找别的网站网页存不存在
: 好像都找不到耶~~都显示不存在....明明就有网页阿
: 只有试自己电脑的网页存不存在~~能够正确显示出来
: $bb='http://member.ettoday.com/book/function.php-is_file.htm '
: if (file_exists($bb)) {
: echo "The file $filename exists";
: } else {
: echo "The file $filename does not exist";
: }
: 还是说有别的函式可以用的 感谢大大
参考一下 php 官方网站的 function 说明
http://tw.php.net/file_exists
file_exists 并不能直接测试远端档案是不是存在
不过底下的 User Contributed Notes 有人提供测试的方法:
$fileUrl = "
http://www.examplecom/test.jpg";
$AgetHeaders = @get_headers($fileUrl);
if (preg_match("|200|", $AgetHeaders[0])) {
// file exists
} else {
// file doesn't exists
}
php 网站的 User Contributed Notes 真的是挖宝的好地方啊..
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 211.23.214.146
1F:推 phpasp:大感谢~~~~~~~~~~~ 08/29 15:08