2017-08-28 66 views
0

我使用這個腳本,看.text的文件的內容 -爲什麼我不能看到我的.txt文件,從這個php腳本

<?php 

$file = fopen("Gin_List_Website.txt","r"); 

if(!file) 
{ 
    echo("ERROR:cant open file .. :("); 
} 
else 
{ 
    echo("opened the file .. :)"); 

    $buff = fread ($file,filesize("Gin_List_Website.txt")); 
    print $buff; 
    echo $buff; 
} 
?> 

但所有我看到的是這一行

opened the file .. :)

我在做什麼錯?

+1

如果你只是想完整的文件,爲什麼不使用'file'或'file_get_contents'? – chris85

+4

如果(!文件)更改爲if(!$文件) –

+0

@bharatparmar我錯過了,現在它給出錯誤.. –

回答

1

首先,您需要更改if(!file)if(!file)。

下面是更簡單的代碼示例:

<?php 
    $file = fopen("Gin_list_Website.txt", "r") or die("Unable to open file!"); 
    echo fread($file,filesize("Gin_list_Website.txt")); 
    fclose($file); 
?> 
+0

我得到'無法打開文件!'錯誤,我的php文件與我的.text文件位於同一目錄中 –

+0

您是否已經爲您的「Gin_List_Website.txt」文件設置了正確的權限?您的文本文件名和擴展名是什麼? –

+0

this是.txt f的路徑ile .. http://www.thelabmultiplayer.com/ewExternalFiles/Gin_list_Website.txt –

相關問題