Jump to content

include files


adam291086

Recommended Posts

The best way to handle your include folders is a file of constants in your root folder

<?php
//All constants used on the site
define("ROOT",$_SERVER['DOCUMENT_ROOT']."/ROOT/");
define("BASE", "http://mysite.com/FOLDERROOT/");
define("SCRIPTS", ROOT."scripts/");
define("SUB_FOLDER", BASE."source/");
define("GRAPHICS", BASE."graphics/");
define("SOURCES", BASE."sources/");
define("IMAGES", BASE."images/");
define("CSS", BASE."css/");
define("EXT", ".php");
?>

So when you go to include stuff on your server first track down this file (only context you will need a path for)

<?php
require_once("../constants.php");
require_once(SCRIPTS."/functions.php");
require_once(SCRIPTS."/sql_functions.php");
?>

That way if you move stuff everything updates.

 

The ROOT is for internal pointers the BASE is for urls and images for html linking

Link to comment
Share on other sites

so you are trying to link to data outside your domain?

are you trying to do something like:

root:

Domain 1:

index file for domain 1

Want index to include the include in domain 3

Domain 2:

index file for domain 2

Domain 3:

index file for domain3

include File for domain 1

Domain 4:

index file for domain 4

 

If so you will probably need to go remote and use file_get_contents of the included file

Link to comment
Share on other sites

Well i have all my php in one file. For example my database config.php. I want to be able to store this file once. At the moment i am include '../database/config.php'. This works fine else where. But in the folder where the server points to it cant find the file.

 

How would i use file_get_contents?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.