L'argomento ENT_QUOTES è opzionale ma utile per poter convertire anche gli apici (in caso di interazione col DB) in entità HTML.Codice PHP:
<?php $file=(isset($_GET['txt']))?$_GET['txt']:"default";
$risorsa = "testo/$file.txt";
$string = file_get_contents($risorsa);
echo nl2br(htmlentities($string, ENT_QUOTES));
?>
![]()