Re: [請益] 請問 file_exists 是不是只能找自己主븠…

看板PHP作者 (不要叫我宅男)時間16年前 (2007/08/29 15:01), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
※ 引述《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

08/29 15:08, , 1F
大感謝~~~~~~~~~~~
08/29 15:08, 1F
文章代碼(AID): #16rHdPjx (PHP)