Re: html news page fed from a text file? [message #387371 is a reply to message #387368] |
Thu, 21 May 2009 14:39 |
|
futura83
Messages: 1285 Registered: July 2006 Location: England
Karma:
|
General (1 Star) Viva la Resistance! |
|
|
reborn wrote on Thu, 21 May 2009 21:53 | Forgive me, I am able to write simple HTML pages, I have never used PHP. I am unsure that the server supports PHP, but if it does, how do I insert PHP code into an HTML page?
|
Put the PHP code after:
and before
To use HTML within PHP use the code:
echo "<HTML CODE GOES HERE>";
Although, you won't be able to use any " in the html code, but you can use ' instead to open and close the echo bit.
Edit:
Use this code to see if your server works with PHP:
<?php
echo "Hello world!";
?>
edit2:
<?php
function file_input($filename)
{
$fo = fopen($filename, 'r');
$read = fread($fo, filesize($filename));
fclose($fo);
echo $read;
}
?>
That should put the contents of the file into the page, exactly as the file is written.
Put that ANYWHERE in your page and then do:
<?php file_input('test.txt'); ?>
Replacing test.txt with the right filename.
That way you can call it multiple times in one page with different files without having to copy and past the same text.
even if you don't, you can put the main bit out of the way and call only the funtion where you want it, to make your code look tidier.
Yes, i just manipulated the info from what goztow posted but i wanted to feel useful.
This is a signature. Reading this is wasting your time.
[Updated on: Thu, 21 May 2009 15:22] Report message to a moderator
|
|
|