Search code examples
phpwindowshtmlnetbeansfopen

fopen in html5 doesn't display anything


I need to display a .txt file in read and write, but the file didn't appeared in my div #div11

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

I've made a test before to know if $fichier was equal to NULL but it's not the case.

I've looked "Developer tools" of chrome too, and there's nothing between the marks of my div


Solution

  • You are just opening a file handle an close it afterwards, you don't output or even access the content of the file. If you just want to output the file contents, use something different, e.g. readfile('/path/to/File') or echo file_get_contents('/path/to/File');.

    If you still want to use fopen, take a look at the fgets() function in the manual.