PHP Include Text File And Format
I have a simple text file. The file name is kpop.txt - What I want to do is include the contents of the file in a webpage. I am using php for includes (header / footer stuff). I w
Solution 1:
I would suggest you use CSS, rather than the deprecated <font>
tag:
<pre style="font-size:120%">
<?php echo file_get_contents('kpop.txt') ?>
</pre>
Solution 2:
So this is what I came up with.
<pre>
<?php
//Read in the file and increase the font 200%
$TAF = file_get_contents("kpop.txt");
echo "<div style='font-size:200%'><p>$TAF</p></div>";
?>
</pre>
It may not be pretty but it works. Thank you all for your help.
Solution 3:
It's pretty simple, use fopen()
and then read it fread()
,just use echo
to display it:
<?php
$myfile = fopen("kpop.txt", "r") or die("Unable to open file!");
echo '<span style="font-size:30px;">' . fread($myfile,filesize("kpop.txt"))
. ' </span>';
fclose($myfile);
?>
More details: https://www.w3schools.com/php/php_file_open.asp
Post a Comment for "PHP Include Text File And Format"