Forum Moderators: coopster

Message Too Old, No Replies

include setup.php in other folders

either or

         

russgri

2:59 pm on Jul 8, 2004 (gmt 0)

10+ Year Member



If I were to have setup.php in public_html/inc I would call it thus;

$inc = $_SERVER["DOCUMENT_ROOT"]."/inc";
include ($inc."/setup.php");

If I were to want the option to include setup.php in public_html/about as well as public_html, I would I call it thus;
Note the placement of the colin

$inc = $_SERVER["DOCUMENT_ROOT"]."/inc";
include ($inc.:"/setup.php");

I am not clear on how to call it.
The main reason would be to change the title and keywords but I wonder if like keywords...

$meta_keywords = 'keyword1 keyword2 keyword3';//in public_html/inc

and in public_html/about I want to show:

$meta_keywords = 'keyword4 keyword5 keyword6';

In other words does it override and ignore like css or does it completely render public_html/inc/setup.php irrelevant?

coopster

3:35 pm on Jul 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The post and your question is a bit confusing, so let me start with an explanation and then maybe you can tell us what you are attempting to do...

PHP has an include_path [php.net], which specifies a list of directories where the include() function looks for files. The format is like the system's PATH environment variable: a list of directories separated with a colon in Unix or semicolon in Windows.

The include() function, includes and evaluates the specified file. Files for including are first looked in

include_path
relative to the current working directory and then in include_path relative to the directory of current script.

If you are attempting to set the include_path in the include function, you are going to get errors.

russgri

4:48 pm on Jul 8, 2004 (gmt 0)

10+ Year Member



Conclusion:
I should not use the parenthesis...function
$inc = $_SERVER["DOCUMENT_ROOT"]."/inc";
include $inc ".:/setup.php";

This would allow me to place setup.php in certain folders that need different keywords etc;

Warboss Alex

5:25 pm on Jul 8, 2004 (gmt 0)

10+ Year Member



I'd suggest sort your site into folders, i.e. root, folder1, folder2, etc.

In every page, include the setup file from the root folder, and the folder-specific setup file for page-specific options.

Something like ..

//a_page.php

include_once $_SERVER['DOCUMENT_ROOT']."/setup.php";
include_once "./setup.php";

That's how I've got everything, and it works quite well. The root folder has common functions/variables/configuration stuff, and the folders have their own files.. i.e. the 'forums' folder would have 'forums'-specific functions and classes included in every file in it.

Just a suggestion!

Alex ...