Including Files With PHP

sk1tL1L

New Member
Messages
59
Reaction score
0
Points
0
Very Simple, but some people do not know how to do it.
Ok if i had header.php and footer.php. Insted of Puting "Third Floor programming" on the top of everypage and "Copyright" On the bottem. I Can Type into a php document:
PHP:
<?php include 'header.php'; ?>
So on Index.php it will show the header. You can do it on everypage. And you only have to change the one file to change the header of ALL the pages you but the code on. Eg.
PHP:
<?php include 'header.php'; ?>
<b>Welcome</b> To my site!.
<?php include 'footer.php'; ?>
Simple?
I Think So

---
sk1tL1L
http://thirdfloor.x10hosting.com
Soon to be: http://thirdfloorprogramming.com
 

Fedlerner

Former Adm & Team Manager
Community Support
Messages
12,934
Reaction score
6
Points
38
Yes, simple but usefull.
I knew this but i know very little of PHP :D

Thanks man!
fedlerner
 

gaspardan

New Member
Messages
1
Reaction score
0
Points
0
except using imagem - to include images in some place your fule use the script for image and after include this file in your principal file.php

INCLUDE ("fileimage.txt").

Right? Daniel

 

unpixelatedgamers

New Member
Messages
674
Reaction score
0
Points
0
for those reading this tutorial, you can include different types of file, ie, .txt or .html if you prefer The includes don't have to be .php, only the file you are including them to.

Just in case someone wasn't sure about that.
 

blacklion524

New Member
Messages
16
Reaction score
0
Points
0
Heres my dilema. My site (www.dead2world.com) has a flash header with a forums tab. So when user click on it they get a phpbb board with my website skin. What i wanted to know is if i can make my flash header appear on my forums instead of the static html one.
 

Bingo

New Member
Messages
2
Reaction score
0
Points
0
In most cases, include is all you need, but I was writing a very complex web app for a job and the require_once command is very useful in some situations. It is implemented the same way. It is useful if you have a header file that you need for a ton of different php files because it only includes the header once.
It's also useful for hack jobs that haven't been well organized :-\
 

yahia

New Member
Messages
338
Reaction score
0
Points
0
I do require() instead of include().
I remember Idid it because include() didn't xant to work on the 1st server.
I dunno if it works now, but I won't be going to change all my pages from require() to include()

Is this a problem or it's okay?
 
Top