Read Data from File with Proper New Line

Read Data from File with proper New Line :
That’s definitely the string written to the file, but what happened to that line break? The newline character means nothing to a Web browser, which renders only HTML. Luckily, the PHP development team had great forethought and created the nl2br() function (newline-to-break; get it?).
<?php
$filename = "e:/ashu.txt";
$myfile = fopen($filename, "r") or
die("Unable to open file");
                                                      $showfile = fread($myfile, filesize($filename));
                                                      $showfile = "<br>nl2br($showfile)<br/>";
                                                      $msg = "The file contents are <p>$showfile</p>";
                                                      ?>
                                                      <?=$msg?>

                                             

                                                  

No comments:

Post a Comment