html5 中的 fopen 不显示任何内容

fopen in html5 doesn't display anything

我需要在读写中显示一个.txt文件,但是这个文件没有出现在我的div#div11

<div id="div11">
<?php
$fichier = fopen("txt/texte.txt", "r+");
fclose($fichier);
?>
</div>

我之前做过测试,想知道 $fichier 是否等于 NULL,但事实并非如此。

我也看过 chrome 的 "Developer tools",我的 div

的标记之间没有任何东西

您只是打开文件,并未显示其内容。

要显示文件内容,您可以这样做:

<?php
echo file_get_contents("txt/texte.txt");
?>

你只是打开一个文件句柄然后关闭它,你不输出甚至访问文件的内容。如果您只想输出文件内容,请使用不同的内容,例如readfile('/path/to/File')echo file_get_contents('/path/to/File');.

如果您还想使用 fopen,请查看 manual 中的 fgets() 函数。