Jump to content

Directory Structure using Sub directories


SharkBait

Recommended Posts

Ok I am having some weird thinking issues and trying to make a website more... universal throughout so hopefully I can explain it well enough to hopefully get some help with it.

 

/index.php

/mysql_connect.php

/funcs.php

/includes/header.html

/includes/footer.html

/products/index.php

 

Ok take that as an example. I want to be able to create a 'global' variable that i can set in /includes/header.html that will allow me to have /products/index.php require /includes/header.html and /includes/footer.html properly.

 

/includes/header.html also includes /mysql_connect.php and /funcs.php

 

Or are /mysql_connect.php and /funcs.php in the wrong place for this to work properly?

 

when i add require('/includes/header.html"); and require("/includes/footer.html"); in the /products/index.php file. I get errors that it can not find the /mysql_connect.php file nor the /funcs.php file.

 

Does this make sense??

Link to comment
Share on other sites

A leading slash on a file system path, like in your examples, refers to the root of the current hard drive.

 

I recommend using absolute file system paths that will work independent of the current working directory and independent of the include_path setting.

 

require($_SERVER['DOCUMENT_ROOT'] . "/includes/header.html");
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.