Jump to content


This topic is now archived and is closed to further replies.


functions on include

Recommended Posts

Hey guys

No code here, just best practice

Lets explain how I set up a website

I create a file which is the header and include
This file contains the doctype, head, and anything in the body that aint the content (navigation ect)
and the div for the content

THen I have a footer file
On here, I have, well, my footer, and close all htm tags

Then on the main page I have something like
$page_title = "My Page";

echo "Hello and welcome, this is the content, all ready to go";


I make a lot of functions
Every form on my websites are in functions
This way I can do something like

echo "Cant you complete a simple form<br />\n";
(I dont have a field that long, each Cap letter is a new word, look closley)
WIth me so far

All this is so my question makes sence

The form functions, I create the function at the top of THAT page, as I am only going to call it on that page

I have functions, they I may call on every page (I have a function to connect to the DB, which is on most pages)
and I have functions, which I may call on 3 out of 20 pages


What is best practice to do these functions

If I call the function more than once, add it to the header include file, so tis there on all pages


Create a new file for functions, function_includes.php or someting


create a class, and call the functions via the class


if i only call it 2 or 3 times, add it to the file thats calling it, if its more, add it to the header file


err, well I cant think of any other way, so let me know what ya tink

The reason for this is, if I have too many functions on the header, then that is being called on EVERY page, and wont it be a stress for PHP to read "Waste Code" as I wont be usning that function on that page

(As you may have clicked, I am a lil crazy, but thats why ya love me)

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.