473,411 Members | 2,289 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Why put all includes in single Include file instead of within each site?

HI,
Just a question out of curiosity - I'm running a few sites on one IP address in Apache, and every tutorial I've found says to put your Includes file in the PHP/Includes folder. However, I much prefer to have an includes file within each site folder that I've created and keep it all together. Can someone please explain if I'm misunderstanding something, or why you should set all includes up in one folder with subfolders??

Thanks!!

Maiya
May 18 '07 #1
4 2566
pbmods
5,821 Expert 4TB
It's really up to you. I never use the global include directory (if I can even remember where I put it!); I define my include_path at runtime:

Expand|Select|Wrap|Line Numbers
  1. ini_set('include_path', ini_get('include_path') . ":$GLOBALS[PATH_PREFIX]/$GLOBALS[PATH_CORE]:$GLOBALS[PATH_PREFIX]/$GLOBALS[PATH_TEMPLATE]");
  2.  
Of course, I develop apps designed to be deployed to separate servers, so it doesn't really make any sense for me to use a global include directory.

On the other hand, if you had several projects, and you were going to serve them all from the same machine, it would save you some hard drive space if you only had to keep one copy of each redundant file. Plus, if you had to make changes to one of those files, you wouldn't have to worry about propagating the changes to six other copies (but then, you DO use version control, right?)

Incidentally, although this is not specific to the PHP/Includes folder, if you store include files outside your site root, they can't be accessed except via include (ok, and require) statements inside your code. E.g., you could store your MySQL login script here so that nobody could access it directly.
May 19 '07 #2
thanks!! Sorry for my ignorance (i'm still very new at this) but do you have to put this code

ini_set('include_path', ini_get('include_path') . ":$GLOBALS[PATH_PREFIX]/$GLOBALS[PATH_CORE]:$GLOBALS[PATH_PREFIX]/$GLOBALS[PATH_TEMPLATE]");

at the beginning of each page, or is there a way to specify that all of your includes are in the (site root)/includes folder?
May 19 '07 #3
pbmods
5,821 Expert 4TB
thanks!! Sorry for my ignorance (i'm still very new at this) but do you have to put this code

ini_set('include_path', ini_get('include_path') . ":$GLOBALS[PATH_PREFIX]/$GLOBALS[PATH_CORE]:$GLOBALS[PATH_PREFIX]/$GLOBALS[PATH_TEMPLATE]");

at the beginning of each page, or is there a way to specify that all of your includes are in the (site root)/includes folder?
I actually pulled this code out of my frameworks; none of those globals are defined by default. I store them in the database and then pull them at the start of script execution so I can keep my projects as portable as possible.

You'll probably want to use something like this:

Expand|Select|Wrap|Line Numbers
  1. ini_set('include_path', ini_get('include_path') . ":$_SERVER['DOCUMENT_ROOT']/Includes:$_SERVER['DOCUMENT_ROOT']/path/to/your/project/IncludesOrWhateverYouWantToCallIt");
  2.  
And so on. Just make sure that each item is separated by a ':' (you also need to separate the original include path [ini_get('include_path')] from your custom include path, hence the ':' at the start of the string as well).
May 19 '07 #4
thanks so much!! I'll see how it goes..
May 24 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Patrick | last post by:
I have an ASP site with about 50 ASP files, all of which are currently including a common "includes.asp" file near the top of the file, responsible for generating the <HEAD/> section of the HTML ...
10
by: Chris Gordon-Smith | last post by:
I am currently revisiting the code of a C++ application and restructuring the code where appropriate to make it consistent with the overall logical design. As part of this, I am looking at the...
7
by: MyndPhlyp | last post by:
I am building up a library of Class'es that represent various columns of table layouts. One often used column is "name" and each occurrence is treated identically. (What a concept, eh?) Part of...
8
by: Jim | last post by:
Hi: Do we have some common style for includes when working on a project with lots of c and h files. Wat I mean is do we have a rule in C when a file includes several files and those file in turn...
10
by: Ben Taylor | last post by:
Hi, Coming from VB, I've still not really grasped the way how in C++ if function A wants to call function B, then function B has to be before function A in the compilation, and #includes that use...
1
by: Steve | last post by:
Hi, I am a newbie to ASP.NET, and just recently started ASP. I have several Questions. 1. I am creating a web page with two drop down lists, which draw data from the database depending on...
6
by: Richard | last post by:
I am new to php and am looking for some quick "get up and go" help. What would the arguments for and against be for function declarations v simple include? e.g <?php include("myfunc.php");...
6
by: MaiyaHolliday | last post by:
Hello, I've recently installed apache on a new computer, and cannot figure out why my site will not process any includes. (it was working on my old one) There are no errors on the page such as...
4
by: Ron | last post by:
Hi all, Trying to work out a few problems in using php on my site. Partially this is a html question. I was reading a lot of the posts and it seems that some of the includes people are using are...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.