Jump to content

[2 PART] Defining a root dir & defining page


timmy0320

Recommended Posts

[PART 1]

Alright I have defined some constants for my root directory of files.

 

define("ROOT_DIR", "/new_work/");
define("ROOT_URL", "http://" . $_SERVER['HTTP_HOST']."".ROOT_DIR."");

 

This function works until I use it in a sub-directory. Now I figured out that I had to turn on allow_url_include on my php.ini settings. I did that and now works. (session.php includes constants.php which contains the above constants)

 

include("../session.php");
include("".ROOT_URL."templ/header.php");

 

Now I'm making my pages all on my computer and personally hosting them before I upload anything to my Webhost. I've read that a lot of web hosts (and Yes I do plan on contacting mine) have this option turned off . I am having trouble figuring out how to do this without linking it by URL . I can do just the ROOT_DIR but then my pages in the sub-directories link wrong. Sub-directories will then link as /dir/include when it's supposed to be just /include/ from the main directory. Any tips on a better way?

 

 

[PART 2]

 

I define all my pages at the top.

 

define('MYSITE', true);

 

All of my includes are as:

 

if (!defined('MYSITE')) { exit; }

 

All of my includes are including except my header and footer and they are all setup the same way and I am lost as to why it's doing this just for those two files. Could it be the order of my includes or what's the deal with this all of a sudden not working? It's only doing it in the sub-directory and the define() are at the TOP of the page before includes.

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/92710-2-part-defining-a-root-dir-defining-page/
Share on other sites

Archived

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

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