有個問題很神奇~哪位大神幫忙回答一下咧?
file_exists($filename)
is_file($filename)
is_writeable($filename)
is_readable($filename)
這幾個判斷文件是否存在的方法,
我確定test文件是存在的,但是在判斷的時候輸出的是不存在~這是什么鬼?是因為www文件目錄下的讀寫權限嗎?如果是讀寫權限的話~為什么file_get_content()這個方法會讀出里邊的內容來?
file_exists($filename)
is_file($filename)
is_writeable($filename)
is_readable($filename)
這幾個判斷文件是否存在的方法,
我確定test文件是存在的,但是在判斷的時候輸出的是不存在~這是什么鬼?是因為www文件目錄下的讀寫權限嗎?如果是讀寫權限的話~為什么file_get_content()這個方法會讀出里邊的內容來?
2018-08-09
舉報
2018-08-13
可能是文件路徑問題?雙引號改為單引號?或者路徑不加http之類的?試一下?
我的就很正常,排除法的話就只有$filename變量的值和你的不一樣
輸出 :this is for testing file operation.
2018-12-23
$isfile = file_exists($fileName) ? "使用file_exists函數判斷文件存在。" : exit("文件不存在!") ;
echo $isfile,"<br />";
$isfile = is_file($fileName) ? "使用is_file函數判斷文件存在。" : exit("文件不存在!") ;
echo $isfile,"<br />";
$isfile = is_readable($fileName) ? "使用is_readable函數判斷文件存在。" : exit("文件不存在!") ;
echo $isfile,"<br />";
$isfile = is_writable($fileName) ? "使用is_writable函數判斷文件存在。" : exit("文件不存在!") ;
echo $isfile,"<br />";
當文件不存在,使用exit退出腳本,節省資源。
2018-08-14
謝謝~回頭試試~
2018-08-13
輸出結果全是:files nonentity//不存在
2018-08-12
輸出結果是什么,貼一下。