<?php foreach (glob("*.html") as $filename) { echo ""$filename\n"."<br>"; } ?> 

My page displays a list of html files in the directory, how to make these files be links, and not just names?

  • add to them the HTML code that forms the link? - Ipatiev
  • @ Ipatiev And how to do this? - Pavel
  • What exactly? HTML link? You can for example open the ABC for beginner webmasters. - Ipatiev
  • @ Ipatiev .... umm, it came to me exactly, HTML. for sure. I break my head as if pulling it out in a puff - Pavel
  • Ipatiev - you can, for example, write the answer, how to do it, and give a link to the primer, as did @koks_rs, instead of writing sentences that were useless to the question author. Or do you think that if you know this, then everyone else should know? - Miron

1 answer 1

To display links you need to use the <a> tag

 foreach (glob("*.html") as $filename) { echo "<a href='$filename' >Имя файла</a><br>"; } 

And of course, in this case, in $filename you should have a valid path to your file on the server.

Read more here.