html - PHP ReadFile Outputs an Indent? -


i'm using php code import text file html document. reason because i'm having page refresh every often, text new. here code:

<!doctype html>  <head>      <meta http-equiv="refresh" content="5">  </head>  <body>      <xmp>     <?php          $date = date("y-m-d");          $file = "..\\chat logs\\$date.txt";         readfile($file);      ?>     </xmp>  </body>  </html> 

the $date.txt file has no special spacing. no indents. problem first line has output:

        [ 00:57:45 ] : <overlord> enemy spotted [ 01:00:51 ] : <shadowlordgamin> hi  [ 01:00:58 ] : <shadowlordgamin> got game today :d [ 01:06:42 ] : <brazdnt> d:  

is there way remove initial indentation? appreciated. thanks.

first off, <xmp> deprecated , badly supported. should use <pre> instead , escape text using htmlspecialchars() (which requires read text file_get_contents() instead of readfile()).

(edit: it's not deprecated, it's dangerous, because opens site cross-site scripting exploits.)

to problem: <xmp> (and <pre>) display characters literally between opening , closing tags, including spaces use formatting code. need make sure no spaces between html opening tag , <?php opening tag:

<pre><?php     $date = date("y-m-d");      $file = "..\\chat logs\\$date.txt";     echo htmlspecialchars(file_get_contents($file)); ?></pre> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -