Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » General Discussions » General Discussion » html news page fed from a text file?
Re: html news page fed from a text file? [message #387371 is a reply to message #387368] Thu, 21 May 2009 14:39 Go to previous messageGo to previous message
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:

<?php



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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: WolframAlpha - Answers your questions
Next Topic: 'Tiberium' First Person Shooter Features
Goto Forum:
  


Current Time: Sat Nov 30 16:48:44 MST 2024

Total time taken to generate the page: 0.00780 seconds