4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 PHP: Echoing another file
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
fgidigi
Junior WebHelper
Junior WebHelper


Joined: 07 Sep 2003
Posts: 16

PostPosted: Sun Sep 07, 2003 12:50 pm (14 years, 3 months ago) Reply with QuoteBack to Top

Hi there,

I'm a newbee, I don't know much about php, so i am learning the basics. I got my 'hello world' test working.
Now I wanna display (echo) the contents of another file {for instance a text file, php or htm - file} into let's say the middle of an excisting htm file, using php.

I tried the test with 'inc' [which i read in the tutorial] but did not succeed.

can someone help me out?

thank you / Figidigi
OfflineView User's ProfileFind all posts by fgidigiSend Personal Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Sun Sep 07, 2003 1:24 pm (14 years, 3 months ago) Reply with QuoteBack to Top

you can use include(), require() and also fread() (http://www.php.net/manual/en/function.fread.php)

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Sep 07, 2003 1:47 pm (14 years, 3 months ago) Reply with QuoteBack to Top

You'll have to rename your .html file to something.php, and then put this code where you want to echo the other file:

Code:
<?php include ('name_of_other_file.php_or_html_or_whatever'); ?>

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
SfCommand
Senior WebHelper
Senior WebHelper


Joined: 10 Nov 2002
Posts: 143
Location: UK

PostPosted: Sun Sep 07, 2003 2:01 pm (14 years, 3 months ago) Reply with QuoteBack to Top

You could always use SSI to include a file into a (s)html file.

________________________________
Miguel

http://community.34sp.com
http://www.miguel.me.uk | http://www.sfcommand.co.uk | http://www.ssdg.org.uk
OfflineView User's ProfileFind all posts by SfCommandSend Personal MessageVisit Poster's Website
fgidigi
Junior WebHelper
Junior WebHelper


Joined: 07 Sep 2003
Posts: 16

PostPosted: Sun Sep 07, 2003 2:24 pm (14 years, 3 months ago) Reply with QuoteBack to Top

Daniel...

* sigh * i've been trying so long and hard before I used your forum and I felt like a moron for not succeeding.

The thing was ... i kept using the HTM file as a basis.
because manuals told me it was INBEDDED in htm, so I named mine test.htm.
In that test - file I tried to put the php script ... WRONG, me silly cow.

your first phrase was essential! I had to rename the extension into php
then it would work...

I am really really really happy - finally I see some php results.

Great and thanx for writing so clearly. Smile
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
figidigi
OfflineView User's ProfileFind all posts by fgidigiSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Sep 07, 2003 2:27 pm (14 years, 3 months ago) Reply with QuoteBack to Top

Hey, I know what it feels like to spend hours working on a problem only to find out something simple is wrong. You feel like banging your head against a brick wall Very Happy

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.054757 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme