如何从txt文件中获取文本

I'm creating a html template with notification under nav bar , and admin can change that notification from the system the text of notification bar will be from notetxt file from the same location path where index.html is located i ave tried

<?php
foreach (glob("note.txt") as $filename) { 
  readfile($filename);
}
?>

and many other way but nothing happens it still stay blank

i'm using this code in pure html file

You can't use PHP functions in plain HTML file. MUST be written in a PHP file.

You have now in your code:

<span>
<!--?php

 foreach (glob("note.txt") as $filename) { 
 $fileArr = file_get_contents($filename);
 }
?-->
</span>

Try with the examples above in a proper PHP file... then must work.

You are not echoing out the content of the textfile.

do it like this:

$myFile = "note.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;

This will output your content of the file.

you can use file_get_contents function, try something like this :

<?php

 foreach (glob("note.txt") as $filename) { 
 $fileArr = file_get_contents($filename);
 }
?>

It's very simple use file_get_contents();

<?= file_exists('note.txt') ? file_get_contents("note.txt") : "file doesn't exists"; ?>

That is all what you need. file_get_contents() get the content of file and returns it. I've also checked if file exists because it may be your problem. Also make sure you have proper rights to read the file(CHMOD) and file is not empty.